const ethereum = new KojiBackend.web3.providers.ethereum({ res });
Provides utility methods for improving the performance and functionality of your Koji app.
Instantiates the Ethereum class.
config
- BackendConfigurationInput, Configuration information for the Koji app.
chain
- SupportedChain
const ethereum = new KojiBackend.web3.providers.ethereum({ res });
Get an account’s balance for an ERC1155 token.
contractId
- String, The ID of the smart contract
accountAddress
- String, The address of the account to query
tokenId
- String, The ID of the specific token for which to return a balance
Promise<Number>
const balance = await ethereum.getERC1155Balance(
'0x495f947276749ce646f68ac8c248420045cb7b5e',
'0x1e093bacf9d51c7fad20badf049b2fb926003e73',
'13585698947536714042189813736898920110951234445351156220539561948976043261953',
);
Get an account’s balance for multiple ERC1155 token IDs.
contractId
- String, The ID of the smart contract
accountAddress
- String, The address of the account to query
tokenIds
- String, An array of token IDs
Promise<[index: string]: any>
const balances = await ethereum.getERC1155BalanceBatch(
'0x495f947276749ce646f68ac8c248420045cb7b5e',
'0x947e4b6e3c2383827fb1a1ace9b191f669089979',
[
'13585698947536714042189813736898920110951234445351156220539562030339903717377',
'13585698947536714042189813736898920110951234445351156220539561952274578145281',
'91545914907022949088754081908633048759965252325794344822483278837725871996929',
],
);
Get an account’s balance for an ERC721 token.
contractId
- String, The ID of the smart contract
accountAddress
- String, The address of the account to query
Promise<Number>
const balance = await ethereum.getERC721Balance(
'0xa3aee8bce55beea1951ef834b99f3ac60d1abeeb',
'0x1702a1e7b9823e8e73efc19be25eea2712b9de22',
);
This method is sometimes used by frontend web3 libraries to determine if a client is connected. We’ll always be connected in the server context, so we simply stub it out here.
Promise<Boolean>
Pass an RPC request through to the node.
args
- Web3Request, A web3 request to proxy
Promise<Web3RequestResult>
Configuration information for the Koji app.
projectId
- String (Optional), Unique identifier for the Koji app. Will override data passed through `res`.
projectToken
- String (Optional), Secret key for the Koji app. Will override data passed through `res`.
res
- Response (Optional), Express response object. Used in conjunction with middleware to scope environment variables for customized versions of the original Koji app. For the original definition see [[https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/express/index.d.ts#L127 | @types/express]].
A web3 request to proxy
method
- String
params
- Any[] (Optional)
Result of a proxied web3 request
error
- (Optional)
result
- Unknown
Supported chains