Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Web3Private

Class containing methods for executing the functions of contracts and sending transactions in order to change the state of the blockchain. To get information from the blockchain use Web3Public.

Hierarchy

  • Web3Private

Index

Constructors

  • new Web3Private(walletConnectionConfiguration: WalletConnectionConfiguration): Web3Private
  • Parameters

    • walletConnectionConfiguration: WalletConnectionConfiguration

      Provider that implements {@link WalletConnectionConfiguration} interface. The provider must contain an instance of web3, initialized with ethereum wallet, e.g. Metamask, WalletConnect.

    Returns Web3Private

Accessors

  • get address(): string

Methods

  • approveTokens(tokenAddress: string, spenderAddress: string, value: BigNumber | "infinity", options?: TransactionOptions): Promise<TransactionReceipt>
  • Executes approve method in ERC-20 token contract.

    Parameters

    • tokenAddress: string

      Address of the smart-contract corresponding to the token.

    • spenderAddress: string

      Wallet or contract address to approve.

    • value: BigNumber | "infinity"

      Token amount to approve in wei.

    • options: TransactionOptions = {}

    Returns Promise<TransactionReceipt>

    Approval transaction receipt.

  • encodeApprove(tokenAddress: string, spenderAddress: string, value: BigNumber | "infinity", options?: TransactionOptions): Promise<TransactionConfig>
  • Build encoded approve transaction config.

    Parameters

    • tokenAddress: string

      Address of the smart-contract corresponding to the token.

    • spenderAddress: string

      Wallet or contract address to approve.

    • value: BigNumber | "infinity"

      Token amount to approve in wei.

    • options: TransactionOptions = {}

    Returns Promise<TransactionConfig>

    Encoded approve transaction config.

  • executeContractMethod(contractAddress: string, contractAbi: AbiItem[], methodName: string, methodArguments: unknown[], options?: TransactionOptions): Promise<TransactionReceipt>
  • Executes method of smart-contract and resolve the promise when the transaction is included in the block.

    Parameters

    • contractAddress: string

      Address of smart-contract which method is to be executed.

    • contractAbi: AbiItem[]

      Abi of smart-contract which method is to be executed.

    • methodName: string

      Method name to execute.

    • methodArguments: unknown[]

      Method arguments.

    • options: TransactionOptions = {}

    Returns Promise<TransactionReceipt>

    Smart-contract method returned value.

  • executeContractMethodWithOnHashResolve(contractAddress: string, contractAbi: AbiItem[], methodName: string, methodArguments: unknown[], options?: TransactionOptions): Promise<unknown>
  • Executes method of smart-contract and resolve the promise without waiting for the transaction to be included in the block.

    Parameters

    • contractAddress: string

      Address of smart-contract which method is to be executed.

    • contractAbi: AbiItem[]

      Abi of smart-contract which method is to be executed.

    • methodName: string

      Executing method name.

    • methodArguments: unknown[]

      Executing method arguments.

    • options: TransactionOptions = {}

      Additional options.

    Returns Promise<unknown>

  • sendTransaction(toAddress: string, value: string | BigNumber, options?: TransactionOptions): Promise<TransactionReceipt>
  • Sends Eth in transaction and resolve the promise when the transaction is included in the block.

    Parameters

    • toAddress: string

      Eth receiver address.

    • value: string | BigNumber

      Native token amount in wei.

    • options: TransactionOptions = {}

    Returns Promise<TransactionReceipt>

    Transaction receipt.

  • transferTokens(contractAddress: string, toAddress: string, amount: string | BigNumber, options?: TransactionOptions): Promise<TransactionReceipt>
  • Sends ERC-20 tokens and resolves the promise when the transaction is included in the block.

    Parameters

    • contractAddress: string

      Address of the smart-contract corresponding to the token.

    • toAddress: string

      Token receiver address.

    • amount: string | BigNumber

      Integer tokens amount to send in wei.

    • options: TransactionOptions = {}

    Returns Promise<TransactionReceipt>

    Transaction receipt.

  • tryExecuteContractMethod(contractAddress: string, contractAbi: AbiItem[], methodName: string, methodArguments: unknown[], options?: TransactionOptions, allowError?: ((err: Web3Error) => boolean)): Promise<TransactionReceipt>
  • Tries to execute method of smart-contract and resolve the promise when the transaction is included in the block or rejects the error.

    Parameters

    • contractAddress: string

      Address of smart-contract which method is to be executed.

    • contractAbi: AbiItem[]

      Abi of smart-contract which method is to be executed.

    • methodName: string

      Method name to execute.

    • methodArguments: unknown[]

      Method arguments.

    • options: TransactionOptions = {}
    • Optional allowError: ((err: Web3Error) => boolean)

      Check error and decides to execute contact if error is allowed.

    Returns Promise<TransactionReceipt>

  • trySendTransaction(toAddress: string, value: string | BigNumber, options?: TransactionOptions): Promise<TransactionReceipt>
  • Tries to send Eth in transaction and resolve the promise when the transaction is included in the block or rejects the error.

    Parameters

    • toAddress: string

      Eth receiver address.

    • value: string | BigNumber

      Native token amount in wei.

    • options: TransactionOptions = {}

    Returns Promise<TransactionReceipt>

    Transaction receipt.

  • unApprove(tokenAddress: string, spenderAddress: string): Promise<TransactionReceipt>
  • Removes approval for token.

    Parameters

    • tokenAddress: string

      Address of the smart-contract corresponding to the token.

    • spenderAddress: string

      Wallet or contract address to approve.

    Returns Promise<TransactionReceipt>

Generated using TypeDoc