Constellation Network
IntroductionFundamentalsFor DevelopersNode Validators
  • Index
  • Guide
    • Introduction
    • Provider Activation
    • Sending RPC Requests
    • Signing Data
    • Supported Connectors
    • Using External Libraries
  • API Reference
    • Overview
    • Wallet provider API
      • Overview
      • errorTypes
      • version
      • getProvider()
  • Chain Provider API
    • Overview
    • activated
    • chain
    • version
    • on()
    • removeListener()
    • async activate()
    • async onAsync()
    • async removeListenerAsync()
    • async request()
  • Constellation RPC API
    • Overview
    • dag_accounts
    • dag_chainId
    • dag_getBalance
    • dag_getMetagraphBalance
    • dag_getMetagraphPendingTransaction
    • dag_getMetagraphTransaction
    • dag_getPendingTransaction
    • dag_getPublicKey
    • dag_getTransaction
    • dag_requestAccounts
    • dag_sendMetagraphTransaction
    • dag_sendMetagraphDataTransaction
    • dag_signMetagraphDataTransaction
    • dag_sendTransaction
    • dag_signData
    • dag_signMessage
    • wallet_watchAsset
    • dag_delegatedStake
    • dag_withdrawDelegatedStake
    • dag_allowSpend
    • dag_tokenLock
  • Ethereum RPC API
    • Overview
    • eth_accounts
    • eth_blockNumber
    • eth_call
    • eth_chainId
    • eth_estimateGas
    • eth_gasPrice
    • eth_getBalance
    • eth_getBlockByHash
    • eth_getBlockByNumber
    • eth_getBlockTransactionCountByHash
    • eth_getBlockTransactionCountByNumber
    • eth_getCode
    • eth_getFilterChanges
    • eth_getFilterLogs
    • eth_getLogs
    • eth_getStorageAt
    • eth_getTransactionByBlockHashAndIndex
    • eth_getTransactionByBlockNumberAndIndex
    • eth_getTransactionByHash
    • eth_getTransactionCount
    • eth_getTransactionReceipt
    • eth_getUncleByBlockHashAndIndex
    • eth_getUncleByBlockNumberAndIndex
    • eth_getUncleCountByBlockHash
    • eth_getUncleCountByBlockNumber
    • eth_newBlockFilter
    • eth_newFilter
    • eth_protocolVersion
    • eth_requestAccounts
    • eth_sendTransaction
    • eth_signTypedData
    • eth_signTypedData_v4
    • eth_uninstallFilter
    • net_version
    • personal_sign
    • web3_sha3
  • Resources
    • Stargazer Github
    • Stargazer Connector Github
    • Stargazer Demos Github
    • Stargazer Chrome
    • Stargazer Android
    • Stargazer IOS
    • EIP-1193
Powered by GitBook

Main

  • Website
  • Get DAG
  • Explore Projects
  • Partners

Socials

  • Telegram
  • Discord
  • X (Twitter)

Tools

  • Wallet
  • DAG Explorer
  • Coingecko

© 2025 CONSTELLATION NETWORK

On this page

Was this helpful?

Export as PDF
  1. Constellation RPC API

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"
Previousdag_allowSpendNextEthereum RPC API

Last updated 1 month ago

Was this helpful?