Ecoweb3

Ecoweb3

new Ecoweb3(provider)

Source:
Ecoweb3 constructor.
Parameters:
Name Type Description
provider string | Ecoweb3Provider Either URL string to create HttpProvider or a Ecoweb3 compatible provider.

Methods

ApiProvider()

Source:
the API service's method needed to configure api

backupWallet(destination) → {Promise}

Source:
Backs up the wallet.
Parameters:
Name Type Description
destination string The destination directory or file.
Returns:
Success or Error.
Type
Promise

Contract(address, abi) → {Contract}

Source:
Constructs a new Contract instance.
Parameters:
Name Type Description
address string Address of the contract.
abi array ABI of the contract.
Returns:
Contract instance.
Type
Contract

dumpPrivateKey(address) → {Promise}

Source:
Reveals the private key corresponding to the address.
Parameters:
Name Type Description
address string The ecochain address for the private key.
Returns:
Private key or Error.
Type
Promise

encryptWallet(passphrase) → {Promise}

Source:
Encrypts the wallet for the first time. This will shut down the ecochain server.
Parameters:
Name Type Description
passphrase string The passphrase to encrypt the wallet with. Must be at least 1 character.
Returns:
Success or Error.
Type
Promise

ercToken()

Source:
ERC-20 Token Contract Implementation

fromHexAddress(hexAddress) → {Promise}

Source:
Converts a hex address to an ecochain address.
Parameters:
Name Type Description
hexAddress string ecochain address in hex format.
Returns:
ecochain address or Error.
Type
Promise

getAccount(address) → {Promise}

Source:
Gets the account name associated with the ecochain address.
Parameters:
Name Type Description
address string The ecochain address for account lookup.
Returns:
Account name or Error.
Type
Promise

getAccountAddress(acctName) → {Promise}

Source:
Gets the ecochain address based on the account name.
Parameters:
Name Type Description
acctName string The account name for the address ("" for default).
Returns:
ecochain address or Error.
Type
Promise

getAddressesByAccount(acctName) → {Promise}

Source:
Gets the ecochain address with the account name.
Parameters:
Name Type Description
acctName string The account name ("" for default).
Returns:
ecochain address array or Error.
Type
Promise

getBlockchainInfo() → {Promise}

Source:
Returns various state info regarding blockchain processing.
Returns:
Latest block info or Error.
Type
Promise

getBlockCount() → {Promise}

Source:
Returns the current block height that is synced.
Returns:
Current block count or Error.
Type
Promise

getBlockHash(blockNum) → {Promise}

Source:
Returns the block hash of the block height number specified.
Parameters:
Name Type Description
blockNum number The block number to look up.
Returns:
Block hash or Error.
Type
Promise

getHexAddress(address) → {Promise}

Source:
Get the hex address of an ecochain address.
Parameters:
Name Type Description
address string ecochain address
Returns:
Hex string of the converted address or Error
Type
Promise

getInfo() → {Promise}

Source:
Get the blockchain info.
Returns:
Blockchain info object or Error
Type
Promise

getNetwork(blockHash, verbose) → {Promise}

Source:
Returns the block info for a given block hash.
Parameters:
Name Type Description
blockHash string The block hash to look up.
verbose boolean True for a json object or false for the hex encoded data.
Returns:
Latest block info or Error.
Type
Promise

getNewAddress(acctName) → {Promise}

Source:
Gets a new ecochain address for receiving payments.
Parameters:
Name Type Description
acctName string The account name for the address to be linked to ("" for default).
Returns:
ecochain address or Error.
Type
Promise

getPeerInfo() → {Promise}

Source:
Returns data about each connected network node as a json array of objects.
Returns:
Node info object or Error
Type
Promise

getTransaction(txid) → {Promise}

Source:
Get transaction details by txid
Parameters:
Name Type Description
txid string The transaction id (64 char hex string).
Returns:
Promise containing result object or Error
Type
Promise

getTransactionReceipt(txid) → {Promise}

Source:
Returns the transaction receipt given the txid.
Parameters:
Name Type Description
txid string The transaction id to look up.
Returns:
Transaction receipt or Error.
Type
Promise

getUnconfirmedBalance() → {Promise}

Source:
Gets the total unconfirmed balance.
Returns:
Unconfirmed balance or Error.
Type
Promise

getWalletInfo() → {Promise}

Source:
Gets the wallet info
Returns:
Promise containing result object or Error
Type
Promise

HttpProvider(urlString) → {HttpProvider}

Source:
Constructs a new HttpProvider instance.
Parameters:
Name Type Description
urlString string URL of the blockchain API. eg. http://username:password@the.no.de.ip:port
Returns:
HttpProvider instance.
Type
HttpProvider

importAddress(address, label, rescan) → {Promise}

Source:
Adds an address that is watch-only. Cannot be used to spend.
Parameters:
Name Type Default Description
address string The hex-encoded script (or address).
label string An optional label.
rescan boolean true Rescan the wallet for transactions.
Returns:
Success or Error.
Type
Promise

importPrivateKey(privateKey, label, rescan) → {Promise}

Source:
Adds an address by private key.
Parameters:
Name Type Default Description
privateKey string The private key.
label string An optional label.
rescan boolean true Rescan the wallet for transactions.
Returns:
Success or Error.
Type
Promise

importPublicKey(publicKey, label, rescan) → {Promise}

Source:
Adds an watch-only address by public key. Cannot be used to spend.
Parameters:
Name Type Default Description
publicKey string The public key.
label string An optional label.
rescan boolean true Rescan the wallet for transactions.
Returns:
Success or Error.
Type
Promise

importWallet(filename) → {Promise}

Source:
Imports keys from a wallet dump file
Parameters:
Name Type Description
filename string The wallet file.
Returns:
Success or Error.
Type
Promise

(async) isConnected()

Source:
Checks if the blockchain is connected.
Returns:
If blockchain is connected.

listAddressGroupings() → {Promise}

Source:
Lists groups of addresses which have had their common ownership made public by common use as inputs or as the resulting change in past transactions.
Returns:
Array of addresses with ECOC balances or Error.
Type
Promise

listContracts(startingAcctIndex, maxDisplay) → {Promise}

Source:
Returns an array of deployed contract addresses.
Parameters:
Name Type Default Description
startingAcctIndex number 1 The starting account index.
maxDisplay number 20 Max accounts to list.
Returns:
Array of contract addresses or Error.
Type
Promise

listLockUnspent() → {Promise}

Source:
Lists temporary unspendable outputs.
Returns:
Array of unspendable outputs or Error
Type
Promise

listUnspent() → {Promise}

Source:
Lists unspent transaction outputs.
Returns:
Array of unspent transaction outputs or Error
Type
Promise

searchLogs(fromBlock, toBlock, addresses, topics, contractMetadata, removeHexPrefix) → {Promise}

Source:
Search logs with given filters
Parameters:
Name Type Description
fromBlock number Starting block to search.
toBlock number Ending block to search. Use -1 for latest.
addresses string | array One or more addresses to search against
topics string | array One or more topic hashes to search against
contractMetadata object Metadata of all contracts and their events with topic hashes
removeHexPrefix bool Flag to indicate whether to remove the hex prefix (0x) from hex values
Returns:
Promise containing returned logs or Error
Type
Promise

sendToAddress(address, amount, comment, commentTo, subtractFeeFromAmount, replaceable, confTarget, estimateMode, senderAddress, changeToSender) → {Promise}

Source:
Lists unspent transaction outputs.
Parameters:
Name Type Default Description
address string Address to send ECOC to.
amount number Amount of ECOC to send.
comment string Comment used to store what the transaction is for.
commentTo string Comment to store name/organization to which you're sending the transaction.
subtractFeeFromAmount boolean false The fee will be deducted from the amount being sent.
replaceable boolean true Allow this transaction to be replaced by a transaction with higher fees via BIP 125.
confTarget number 6 Confirmation target (in blocks).
estimateMode string UNSET The fee estimate mode, must be one of: "UNSET", "ECONOMICAL", "CONSERVATIVE"
senderAddress string The ECOC address that will be used to send money from.
changeToSender boolean false Return the change to the sender.
Returns:
Transaction ID or Error
Type
Promise

setTxFee(amount) → {Promise}

Source:
Set the transaction fee per kB. Overwrites the paytxfee parameter.
Parameters:
Name Type Description
amount bumber The transaction fee in ECOC/kB.
Returns:
True/false for success or Error.
Type
Promise

validateAddress(address) → {Promise}

Source:
Validates if a valid ecochain address.
Parameters:
Name Type Description
address string ecochain address to validate.
Returns:
Object with validation info or Error.
Type
Promise

walletLock() → {Promise}

Source:
Locks the encrypted wallet.
Returns:
Success or Error.
Type
Promise

walletPassphrase(passphrase, timeout, stakingOnly) → {Promise}

Source:
Unlocks the encrypted wallet with the wallet passphrase.
Parameters:
Name Type Default Description
passphrase string The wallet passphrase.
timeout number The number of seconds to keep the wallet unlocked.
stakingOnly boolean false Unlock wallet for staking only.
Returns:
Success or Error.
Type
Promise

walletPassphraseChange(oldPassphrase, newPassphrase) → {Promise}

Source:
Changes the encrypted wallets passphrase.
Parameters:
Name Type Description
oldPassphrase string The old wallet passphrase.
newPassphrase string The new wallet passphrase.
Returns:
Success or Error.
Type
Promise