Skip to main content

Introduction

The Warp team has implemented atomic-asset and tradeable standard in two languages Rust and Typescript. The default implementation is composed from two standards atomic-asset and tradeable.

You can use implementations directly, or leverage libraries which allows to compose own implementations. Thanks to libraries it is up to you, which interfaces will you expose.:::danger

Libraries exposes functions, which as first argument accept current state of contract and return modified state. You should check State section to avoid clash of state fields names. :::

Discoverability

To find existing contracts implementing the atomic-asset standard, we can use tags that are part of every Arweave transaction. Tags can be specified during deployment of atomic-asset.

  • During deployment following tag should be added : {name: 'Indexed-By', value: 'atomic-asset'}

State

These is state structure for both implementations.

  • name
    • ?string
    • Full name of the atomic-asset, can be empty
  • description
    • ?string
    • Description of the atomic-asset, can be empty
  • owner
    • ?string
    • If the contract is NFT then totalSupply == 1 and owner field is set
    • If the contract is fungible token, then totalSupply > 1 and owner field is empty
    • If the contract is fungible token, and totalSupply is owned by one account then owner field is set to this account
  • symbol
    • string
    • symbol representing asset
  • decimals
    • uint
    • The number of decimals the token uses - e.g. 8, means to divide the token amount by 100000000 to get its user representation
  • totalSupply
    • uint
    • Number of tokens that were minted
    • If totalSupply == 1 then contract is NFT (non fungible token)
    • If totalSupply > 1 then contract is fungible token
  • balances
    • Map<string,uint>
    • Represent the mapping from user address to current balance address => balance
  • allowances
    • Map<string,Map<string, uint>>
    • which represent allowance from user given to other users address => (address => allowance_amount)

Rust implementation

  • implementation can be found here
  • library coming soon

Typescript implementation

(npm) npm i atomic-asset-typescript
(yarn) yarn add atomic-asset-typescript
  • Minimal repository showing how to construct own atomic-asset implementation using library, deploy it and interact via bindings.

Deployment

info

Deployment of atomic-asset requires extra step, which is described here

info

Pre-deployed srcTxId are implementing atomic-asset and tradeable interfaces.

Bindings

You can also use javascript/typescript bindings which ease interacting with contract and expose type information. Bindings are available on npm - atomic-asset-js-bindings.

(npm) npm i atomic-asset-js-bindings
(yarn) yarn add atomic-asset-js-bindings

Example

import { AtomicAssetContractImpl } from "atomic-asset-js-bindings";

const warp = WarpFactory.forMainnet();
const atomicAsset = new AtomicAssetContractImpl("contract_tx_id", warp);
const { balance } = await atomicAsset.balanceOf("some_address");