dag_allowSpend

Grants permission for another wallet or metagraph to spend up to a specified amount from the user’s wallet in a metagraph token or DAG.

Parameters

Name
Type
Description

Data

Object<AllowSpend>

The allow spend object.

AllowSpend

type AllowSpend = {

  source: string;             // Wallet address signing the transaction

  destination: string;        // The destination address
                              // Must be a metagraph address

  amount: number;             // The amount to allow spend
                              // Must be in DATUM

  approvers: string[];        // An array with a single DAG address that can atomically approve this operation
                              // Can be a metagraph or wallet address

  currencyId: string | null;  // The currency metagraph identifier
                              // For DAG, this field must be null

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

  validUntilEpoch?: number;   // The global snapshot epoch progress for which this is valid until 
                              // If not provided, the default value will be currentEpoch + 30
                              // Minumum allowed value: currentEpoch + 5
                              // Maximum allowed value: currentEpoch + 60

};

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

Return Type

String<Hash> - The hash of the allow spend transaction.

Example

Last updated

Was this helpful?