dag_tokenLock

Locks a specified amount of tokens of a metagraph token or DAG.

Parameters

Name
Type
Description

Data

Object<TokenLock>

The token lock object.

TokenLock

type TokenLock = {

  source: string;             // Wallet address signing the transaction

  amount: number;             // The amount to lock
                              // Must be in DATUM

  currencyId: string | null;  // The currency metagraph identifier that the user wants to lock
                              // For DAG, this field must be null

  fee?: number;               // The fee in the currency of the currency metragraph, or DAG. 
                              // If not provided, the default fee will be 0
                              // Must be in DATUM

  unlockEpoch: number | null; // The global snapshot epoch progress to unlock the tokens
                              // If provided, must be greater than the currentEpoch

};

The currentEpoch value can be pulled from the latest global snapshot. You can use dag4.js to easily get it:

const latestSnapshot = await dag4.network.l0Api.getLatestSnapshot();
const currentEpoch = latestSnapshot.value.epochProgress;

Return Type

String<Hash> - The hash of the token lock transaction.

Example

await provider.request({
  method: "dag_tokenLock",
  params: [ 
    { 
        source: 'DAG5sz69nNwGF8ypn1yukFpg2pVJpdx5mnf1PJVc',
        amount: 100000000,
        currencyId: 'DAG8RdiwFhZcLmjrsz79jiKfstQmPaSqABphCK1P',
        fee: 0,
        unlockEpoch: 1022060,
    }
  ]
});
// "2d9fe9bad17debed7c903f22b74aac8af270daea7995dd099a58d6b201547169"

Last updated

Was this helpful?