Transactions and Instructions

A transaction on the 1Money Network is a request for the network to execute one or more actions, known as "instructions," in a specified order. The 1Money Network ensures that all instructions within a transaction are completed successfully or not executed at all, thereby guaranteeing atomicity and data integrity.

Below are key details about how transactions are processed:

  • If a transaction includes multiple instructions, the instructions execute in the order they are added to the transaction.

  • Transactions are "atomic" - either all instructions process successfully, or the entire transaction fails and no changes are made.

For simplicity, a transaction can be thought of as a request to process a set of instructions.

Token Instructions

TokenInstruction is an enum that defines all possible operations that can be performed on tokens within the system. Each variant represents a specific action that can be executed on a token, its accounts, or its authorities. This documentation provides detailed information about each instruction, its parameters, required permissions, and usage examples.

Instruction Types

CreateNewToken

Creates a new token with specified parameters. This is the first step in the token lifecycle.

Parameters:

  • symbol: String - The token's symbol (e.g., "USDT", "USDC")

  • decimals: u8 - Number of decimal places for the token (e.g., 6 for USDC, 18 for USDT)

  • master_authority: Address - The address that will have full control over the token

Required Permissions:

  • The transaction signer must match the master_authority parameter

Notes:

  • After creation, the token's master_authority cannot be changed

  • The token's supply starts at zero

  • The token address is derived deterministically from the master_authority and symbol

Transfer

Transfers tokens from one account to another.

Parameters:

  • amount: U256 - The amount of tokens to transfer

  • recipient: Address - The recipient's wallet address

Required Permissions:

  • The transaction signer must be the owner of the source token account

  • The token must not be paused

  • Neither the sender nor recipient can be blacklisted

Notes:

  • The system automatically derives the token accounts for both sender and recipient

  • Transfers fail if the sender has insufficient balance

  • The recipient's token account is created automatically if it doesn't exist

GrantAuthority

Grants a specific authority type to an address.

Parameters:

  • authority_type: AuthorityType - The type of authority to grant

  • new_authority: Address - The address receiving the authority

Required Permissions:

  • For most authority types: The transaction signer must be the token's master_authority

  • For MintTokens: The signer can be either the master_authority or the master_mint_authority

Notes:

  • Each token can have up to 10 authorities of each type (defined by MAX_NUM_AUTHORITIES)

  • For MintTokens, the U256 parameter specifies the minting allowance

  • Some authority types (like MasterMint) can only be granted if not already assigned

RevokeAuthority

Revokes a specific authority from an address.

Parameters:

  • authority_type: AuthorityType - The type of authority to revoke

  • new_authority: Address - The address losing the authority

Required Permissions:

  • For most authority types: The transaction signer must be the token's master_authority

  • For MintTokens: The signer can be either the master_authority or the master_mint_authority

Notes:

  • Revoking an authority is permanent unless granted again

  • For singleton authorities (like MasterMint), the authority is set to EMPTY_ADDRESS

  • For list-based authorities, the address is removed from the list

BlacklistAccount

Adds an account to the token's blacklist, preventing it from participating in token operations.

Parameters:

  • address: Address - The address to blacklist

Required Permissions:

  • The transaction signer must be in the token's black_list_authorities list

Notes:

  • Blacklisted addresses cannot send or receive tokens

  • Blacklisting is effective immediately

  • The token account must exist and be associated with the token

WhitelistAccount

Removes an account from the token's blacklist, allowing it to participate in token operations again.

Parameters:

  • address: Address - The address to whitelist (remove from blacklist)

Required Permissions:

  • The transaction signer must be in the token's black_list_authorities list

Notes:

  • Whitelisting is effective immediately

  • The address must already be in the blacklist

  • The token account must exist and be associated with the token

MintTo

Creates new tokens and adds them to a specified account.

Parameters:

  • amount: U256 - The amount of tokens to mint

  • address: Address - The recipient's wallet address

Required Permissions:

  • The transaction signer must be either:

  • The token's master_authority (unlimited minting)

  • In the token's minter_authorities list with sufficient allowance

  • The token must not be paused

Notes:

  • Minting increases the token's total supply

  • For minter authorities, their allowance is reduced by the minted amount

  • The recipient's token account is created automatically if it doesn't exist

BurnFromAccount

Destroys tokens by removing them from a specified account.

Parameters:

  • amount: U256 - The amount of tokens to burn

  • address: Address - The address from which to burn tokens

Required Permissions:

  • The transaction signer must be in the token's burn_authorities list

  • The token must not be paused

Notes:

  • Burning decreases the token's total supply

  • The account must have sufficient balance

  • Burn authorities can burn from any account, not just their own

CloseAccount

Closes a token account. The account must have zero balance.

Parameters:

  • None

Required Permissions:

  • The transaction signer must be the owner of the token account

  • The token account balance must be zero

Notes:

  • Closed accounts can be reopened automatically when receiving tokens

  • Closing accounts can help reclaim storage resources

Pause

Pauses all transactions for the token.

Parameters:

  • None

Required Permissions:

  • The transaction signer must be the token's pause_authority

Notes:

  • When paused, no transfers, mints, or burns can occur

  • Pausing is effective immediately

  • Useful for emergency situations or scheduled maintenance

Unpause

Resumes all transactions for the token.

Parameters:

  • None

Required Permissions:

  • The transaction signer must be the token's pause_authority

Notes:

  • Unpausing is effective immediately

  • All token operations resume normal functionality

UpdateMetadata

Updates the token's metadata.

Parameters:

  • metadata: TokenMetadata - The new metadata for the token, including:

  • name: String - The token's full name

  • uri: String - URI pointing to additional metadata

  • additional_metadata: Vec<MetaDataKeyValuePair> - Custom key-value pairs

Required Permissions:

  • The transaction signer must be the token's metadata_update_authority

Notes:

  • Metadata updates are effective immediately

  • The URI can point to a JSON file with additional information

  • Additional metadata can store arbitrary key-value pairs

Last updated