Metagraph Tokens

Metagraph tokens work in much the same way as DAG. They share a common transaction format and API interface. Both DAG and metagraph tokens use DAG addresses for their balance maps so a single public/private keypair can control DAG and metagraph token accounts.

Minimum Version

You will need version 2.1.1 or higher in order to interact with metagraph token networks.

Connecting to a metagrapharrow-up-right

In order to interact with a metagraph token you will need to first need to create a connection to the Hypergraph, then create a metagraph client instance to connect to the metagraph and send transactions.

The example below connects to IntegrationNet. Fill in :metagraph-l0-endpoint, :metagraph-currency-l1-endpoint, and :metagraph-id in the code below with the correct details for the metagraph you are connecting to.

const { dag4 } = require('@stardust-collective/dag4');

// Connect to Hypergraph on IntegrationNet or MainNet
dag4.account.connect({
  networkVersion: '2.0',
  beUrl: "https://be-integrationnet.constellationnetwork.io",
  l0Url: "https://l0-lb-integrationnet.constellationnetwork.io",
  l1Url: "https://l1-lb-integrationnet.constellationnetwork.io",
});

dag4.account.loginPrivateKey('MY-PRIVATE-KEY');

// Create a metagraphClient instance to connect to a specific metagraph
const metagraphClient = dag4.account.createMetagraphTokenClient({
  beUrl: "https://be-integrationnet.constellationnetwork.io",
  l0Url: ':metagraph-l0-endpoint',
  l1Url: ':metagraph-currency-l1-endpoint',
  metagraphId: ':metagraph-id'
});

// Make calls directly to the metagraph (check balance, send transactions, etc.)
await metagraphClient.getBalance();
// 100000

Metagraph connection detailsarrow-up-right

A list of existing metagraphs can be found on the DAG Explorerarrow-up-right. On each metagraph's page you'll find the Metagraph ID, as well as L0 and currency L1 endpoints, which are necessary for configuring your metagraph client to connect to a specific metagraph network.

Send a single transactionarrow-up-right

The metagraph client has all the same methods as dag4.account except transferDag becomes transfer and transferDagBatch becomes transferBatch.

Generate bulk transactions offline and sendarrow-up-right

Transaction Fees

Note that transaction fees on metagraph networks are paid in the network's metagraph token, not in DAG.

Last updated

Was this helpful?