UNPKG

@martins-finance/venus-js

Version:

A JavaScript SDK for Ethereum and the Venus Protocol.

89 lines (88 loc) 2.86 kB
import { AbiType } from './types'; /** * A generic HTTP request method that works in Node.js and the Web Browser. * * @param {object} options HTTP request options. See Node.js http.request * documentation for details. * * @hidden * * @returns {Promise<object>} Returns a promise and eventually an HTTP response * (JavaScript object). */ export declare function request(options: any): Promise<any>; /** * Gets the contract address of the named contract. This method supports * contracts used by the Venus Protocol. * * @param {string} contract The name of the contract. * @param {string} [network] Optional name of the Ethereum network. Main net and * all the popular public test nets are supported. * * @returns {string} Returns the address of the contract. * * @example * ``` * console.log('vBNB Address: ', Venus.util.getAddress(Venus.vBNB)); * ``` */ export declare function getAddress(contract: string, network?: string): string; /** * Gets the contract name using the contract address. This method supports * contracts used by the Venus Protocol. * * @param {string} contractAddress The address of the contract. * @param {string} [network] Optional name of the Ethereum network. Main net and * all the popular public test nets are supported. * * @returns {string} Returns the name of the contract. * * @example * ``` * console.log('Contract at this address: ', Venus.util.getNameByAddress(contractAddress)); * ``` */ export declare function getAssetNameByAddress(contractAddress: string, network?: string): string; /** * Gets a contract ABI as a JavaScript array. This method supports * contracts used by the Venus Protocol. * * @param {string} contract The name of the contract. * * @returns {Array} Returns the ABI of the contract as a JavaScript array. * * @example * ``` * console.log('vBNB ABI: ', Venus.util.getAbi(Venus.vBNB)); * ``` */ export declare function getAbi(contract: string): AbiType[]; /** * Gets the name of an Ethereum network based on its chain ID. * * @param {string} chainId The chain ID of the network. * * @returns {string} Returns the name of the Ethereum network. * * @example * ``` * console.log('bnbt : ', Venus.util.getNetNameWithChainId(97)); * ``` */ export declare function getNetNameWithChainId(chainId: number): string; /** * Applies the EIP-55 checksum to an Ethereum address. * * @param {string} _address The Ethereum address to apply the checksum. * * @returns {string} Returns a string of the Ethereum address. */ export declare function toChecksumAddress(address: string): string; /** * Gets the number of decimals of a token * * @param {string} token The name of the token * * @returns {number} Returns the number of decimals used in the token */ export declare function getDecimals(token: string): number;