Start typing to search...

WEB3.providers

Provides utility methods for improving the performance and functionality of your Koji app.

Constructor

Instantiates the Ethereum class.

Parameters

Example

const ethereum = new KojiBackend.web3.providers.ethereum({ res });

Methods

.getERC1155Balance(contractId, accountAddress, tokenId)

Get an account’s balance for an ERC1155 token.

Parameters

  • 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

Returns

Promise<Number>

Example

const balance = await ethereum.getERC1155Balance(
   '0x495f947276749ce646f68ac8c248420045cb7b5e',
   '0x1e093bacf9d51c7fad20badf049b2fb926003e73',
   '13585698947536714042189813736898920110951234445351156220539561948976043261953',
);

Source: backend/web3/providers/ethereum.ts#L151

.getERC1155BalanceBatch(contractId, accountAddress, tokenIds)

Get an account’s balance for multiple ERC1155 token IDs.

Parameters

  • contractId - String, The ID of the smart contract

  • accountAddress - String, The address of the account to query

  • tokenIds - String, An array of token IDs

Returns

Promise<[index: string]: any>

Example

const balances = await ethereum.getERC1155BalanceBatch(
   '0x495f947276749ce646f68ac8c248420045cb7b5e',
   '0x947e4b6e3c2383827fb1a1ace9b191f669089979',
   [
     '13585698947536714042189813736898920110951234445351156220539562030339903717377',
     '13585698947536714042189813736898920110951234445351156220539561952274578145281',
     '91545914907022949088754081908633048759965252325794344822483278837725871996929',
   ],
);

Source: backend/web3/providers/ethereum.ts#L197

.getERC721Balance(contractId, accountAddress)

Get an account’s balance for an ERC721 token.

Parameters

  • contractId - String, The ID of the smart contract

  • accountAddress - String, The address of the account to query

Returns

Promise<Number>

Example

const balance = await ethereum.getERC721Balance(
   '0xa3aee8bce55beea1951ef834b99f3ac60d1abeeb',
   '0x1702a1e7b9823e8e73efc19be25eea2712b9de22',
);

Source: backend/web3/providers/ethereum.ts#L111

.isConnected()

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.

Returns

Promise<Boolean>

Source: backend/web3/providers/ethereum.ts#L63

.request(args)

Pass an RPC request through to the node.

Parameters

Returns

Promise<Web3RequestResult>

Source: backend/web3/providers/ethereum.ts#L73

Interfaces

BackendConfigurationInput

Configuration information for the Koji app.

Properties

  • 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]].

Web3Request

A web3 request to proxy

Properties

  • method - String

  • params - Any[] (Optional)

Web3RequestResult

Result of a proxied web3 request

Properties

  • error -  (Optional)

  • result - Unknown

Type aliases

SupportedChain

Supported chains

Possible values

  • 'ethereum'
  • 'polygon'
  • 'ropsten'
  • 'rinkeby'
  • 'goerli'
  • 'kovan'
  • 'matic_mumbai'