Assets

In Agence, every account can own assets, which can translate to in-game items, etc. The format of information that is stored in the assets.

The asset ID is currently defined as <ForgeID>x<AssetKindID>x<AssetId>, so 3x1111x2 would represent the 2nd created asset from Forge 3 with AssetKind 1111.

View owned Assets

We can check account's owned assets on AgenceExplorer's AccountDetail page:

https://explorer.takecopter.agence.network/<account_address>

image

Currently, the recommended way to store asset data is to store the bulk of the data on IPFS. In the picture above, we are only storing the IPFS hash of the asset on the chain, while the rest of the data is on IPFS.

There, you will find a directory with an attrs.json file to serve as its index file. As we progress, we intend to have standard formats set and iterated upon.

Query AssetKind

Using forgeId + assetKindId, we can query assetKind as follows:

JSON.stringify(await api.query.assets.assetKind([forgeId, assetKindId]))

example output:

'{
    "data_hash": "0x516d616832684b744a597774616d344533346354395447363764614c7574644d7342734878364c79696e4a76424c",
    "data_uri": null,
    "volume": 103
}'

Query Asset

Using forgeId + assetKindId + assetId, we can query asset as follows:

JSON.stringify(await api.query.assets.asset([forgeId, assetKindId, assetId]))

Example output:

'{
    "owner": "SWvNjWfEoTavvuMtM4DLyYKd2Myn6duBeG51vSmbqpcyGuT5","metadata":"0x6d657461"
}'

Transferring Assets

In order to send an asset from one account to another, the following command can be executed:

await api.tx.assets.transfer(destination, [forgeId, assetKindId, assetId]).signAndSend(keypair , result => {console.log(JSON.stringify(result))})

Where destination is the recipient's address.