Class WMAS

Example

const token = new MRC20(provider, <tokenAddr>);
const balance = await token.balanceOf(<accountAddr>);
console.log(`Your balance: ${balance}`);

const transferOperation = await token.transfer(<recipientAddr>, BigInt(10000));
console.log(`Transfer operation id: ${transferOperation.id}`);

Hierarchy (view full)

Constructors

Properties

address: string

Methods

  • Get the MAS balance of the smart contract

    Parameters

    • final: boolean = false

      Whether to get the final balance or the pending balance

    Returns Promise<bigint>

    The MAS balance of the smart contract

  • Parameters

    • addresses: string[]
    • final: boolean = true

    Returns Promise<{
        address: string;
        balance: bigint;
    }[]>

  • Executes a smart contract call operation

    Parameters

    • func: string

      The smart contract function to be called.

    • args: Uint8Array | Args = ...
    • options: CallSCOptions = {}

      Includes optional and required parameters like fee, maxGas, coins, and periodToLive.

    Returns Promise<Operation>

    A promise that resolves to an Operation object representing the transaction.

  • Increases the amount of tokens that spenderAddress can spend on behalf of the caller.

    Parameters

    • spenderAddress: string
    • amount: bigint
    • Optional options: CallSCOptions

    Returns Promise<Operation>

    Remarks

    When options.coins is not set, the storage cost of the allowance entry is sent if the entry does not exist yet. Tokens from MRC20 0.1.0 (such as WMAS once MIP-0002 is active) refund the unused coins and revert if the new entry is not paid for. Older tokens pay the storage themselves and keep the coins.

  • Executes a smart contract read operation

    Parameters

    • func: string

      The smart contract function to be called.

    • args: Uint8Array | Args = ...

      Parameter for the function call in Uint8Array format.

    • options: ReadSCOptions = {}

      Includes optional parameters like fee, maxGas, coins, and periodToLive.

    Returns Promise<ReadSCData>

    A promise that resolves to the result of the read operation.

  • Wraps amount MAS into amount WMAS.

    Parameters

    • amount: bigint

    Returns Promise<Operation>

    Remarks

    deposit deducts the storage cost of the caller's balance entry from the coins it receives when that entry does not exist yet, so this cost is sent on top of amount.

  • Deploy a SmartContract byteCode

    Parameters

    • provider: Provider

      Web3 provider.

    • byteCode: Uint8Array

      Compiled SmartContract bytecode.

    • constructorArgs: Uint8Array | Args = ...

      Parameter for call of constructor function.

    • options: DeploySCOptions = {}

      Includes optional parameters like fee, maxGas, coins, and periodToLive.

    Returns Promise<SmartContract>

    A promise that resolves to the result of the read operation.