Tutorials

Creating your first vAtom
Ethereum enabled vAtom
Writing your first Android app
Writing your first iOS app

Ethereum enabled vAtom

Overview

In this tutorial, we are going to learn how to create a template, template variation, and emit an on-chain vAtom that can be held in your wallet or transferred to another user. While the basics of creating vAtoms is covered in the creating your first vAtom, this tutorial will focus on the blockchain integration. The Ethereum blockchain will be used to track the owner of the vAtom and also store additional state on-chain.

To execute this tutorial you need an App-Id, pub_fqdn, and a valid BLOCKv user with publisher rights. To request these credentials click here.

Create a new Template

To be able to create on-chain vAtoms the template has to contain an eth-object. This tutorial will use the following parameters:

ETH object

{
    "network": "testnet",
    "symbol": "TEST",
    "fields": {
        "hello": {
            "type": "string",
            "value": "Hello Ethereum"
        }
    }
}

The fields object is optional. In case only the ownership of a vAtom should be tracked on the blockchain, network and symbol are the only fields that need to be specified.

The full payload to create the template.

Create a Template with an ETH object

{
    "template": "publisher_fqdn::demo::ETH::Image::v1",
    "public": false,
    "cloneable": false,
    "unpublished": false,
    "eth": {
        "network": "testnet",
        "symbol": "test",
        "fields": {
            "hello": {
                "type": "string",
                "value": "Hello Ethereum"
            }
        }
    },
    "vatom": {
        "vAtom::vAtomType": {
            "root_type": "vAtom::vAtomType",
            "description": "This is an on-chain demo Image Template",
            "title": "Image",
            "redeemable": false,
            "transferable": true,
            "states": [
                {
                    "name": "Activated",
                    "value": {
                        "type": "boolean",
                        "value": "true"
                    }
                }
            ],
            "resources": [
                {
                    "name": "ActivatedImage",
                    "resourceType": "ResourceType::Image::PNG",
                    "value": {
                        "resourceValueType": "ResourceValueType::URI",
                        "value": ""
                    }
                },
                {
                "name": "CardImage",
                "resourceType": "ResourceType::Image::PNG",
                "value": {
                        "resourceValueType": "ResourceValueType::URI",
                        "value": ""
                    }
                }
            ]
        },
        "private": {}
    }
}

Template created

{
    "payload": {
        "success_message": "created Template successfully"
    }
}

At this point, you can run the Get Template call with this newly registered name to verify.

Get Demo Image Template

GET /v1/templates/publisher_fqdn::demo::ETH::Image::v1

You should see something like this:

Get Template

{
    "payload": {
        "name": "publisher_fqdn::demo::ETH::Image::v1",
        "meta": {
            "created_by": "715e0e66-3b18-4719-a927-3e06221ef95b",
            "when_created": "2018-04-23T14:08:03Z",
            "modified_by": "715e0e66-3b18-4719-a927-3e06221ef95b",
            "when_modified": "2018-04-23T14:08:03Z",
            "data_type": "vAtom::vAtomTemplateType"
        },
        "properties": {
            "publisher_fqdn": "publisher_fqdn",
            "template": {
                "vAtom::vAtomType": {
                    "parent_id": ".",
                    "publisher_fqdn": "publisher_fqdn",
                    "root_type": "vAtom::vAtomType",
                    "owner": "715e0e66-3b18-4719-a927-3e06221ef95b",
                    "author": "715e0e66-3b18-4719-a927-3e06221ef95b",
                    "template": "publisher_fqdn::demo::ETH::Image::v1",
                    "template_variation": "",
                    "notify_msg": "",
                    "title": "Image",
                    "description": "This is an on-chain demo Image Template",
                    "disabled": false,
                    "category": "",
                    "tags": [],
                    "transferable": true,
                    "acquirable": false,
                    "tradeable": false,
                    "transferred_by": "",
                    "cloned_from": "",
                    "cloning_score": 0,
                    "in_contract": false,
                    "redeemable": false,
                    "in_contract_with": "",
                    "commerce": {
                        "pricing": {
                            "pricingType": "",
                            "value": {
                                "currency": "",
                                "price": "",
                                "valid_from": "",
                                "valid_through": "",
                                "vat_included": false
                            }
                        }
                    },
                    "states": [
                        {
                            "name": "Activated",
                            "value": {
                                "type": "boolean",
                                "value": "true"
                            },
                            "on_state_change": {
                                "reactor": ""
                            }
                        }
                    ],
                    "resources": [
                        {
                            "name": "ActivatedImage",
                            "resourceType": "ResourceType::Image::PNG",
                            "value": {
                                "resourceValueType": "ResourceValueType::URI",
                                "value": ""
                            }
                        },
                        {
                            "name": "CardImage",
                            "resourceType": "ResourceType::Image::PNG",
                            "value": {
                                "resourceValueType": "ResourceValueType::URI",
                                "value": ""
                            }
                        }
                    ],
                    "visibility": {
                        "type": "owner",
                        "value": "*"
                    },
                    "num_direct_clones": 0,
                    "geo_pos": {
                        "$reql_type$": "GEOMETRY",
                        "coordinates": [
                            0,
                            0
                        ],
                        "type": "Point"
                    },
                    "dropped": false
                },
                "eth": {
                    "symbol": "test",
                    "fields": {
                        "hello": {
                            "type": "string",
                            "value": "Hello Ethereum"
                        }
                    },
                    "network": "testnet"
                },
                "private": {},
                "version": ""
            },
            "cloneable": false,
            "unpublished": false
        }
    }
}

Create a new Template Variation

Only the values for states and resources have to be defined, so the template variation creation is very simple.

Create a Template Variation

{    
  "template": "publisher_fqdn::demo::ETH::Image::v1",
  "template_variation": "publisher_fqdn::demo::ETH::Image::v1::variation::v1",
  "unpublished": false,
  "vatom": {
    "vAtom::vAtomType":{
        "states": [
            {
                "name": "Activated",
                "value": {
                    "type": "boolean",
                    "value": "true"
                },
                "on_state_change": {
                    "reactor": ""
                }
            }
        ],
        "resources": [
            {
                "name": "ActivatedImage",
                "resourceType": "ResourceType::Image::PNG",
                "value": {
                    "resourceValueType": "ResourceValueType::URI",
                    "value": "https://cdn.blockv.io/blockv.templates/publisher_fqdn/demo/eth/image/v1/variation/v1/icon.png"
                }
            },
            {
                "name": "CardImage",
                "resourceType": "ResourceType::Image::PNG",
                "value": {
                    "resourceValueType": "ResourceValueType::URI",
                    "value": "https://cdn.blockv.io/blockv.templates/publisher_fqdn/demo/eth/image/v1/variation/v1/card.png"
                }
            }
        ]
    }
  }
}

Sample Respones

{
    "payload": {
        "success_message": "created TemplateVariation successfully"
    }
}

Since the template contains an eth-object, a smart contract will automatically be created once the template variation is published.

ERC 721

The contract that is created is compatible with the ERC-721 Non-Fungible Token Standard.

Getting the contract information

The contract creation will take some time (ranging from a few minutes to more than an hour, depending on how busy the network is). The contract information can be queried like this:

Get contract information

GET /v1/contracts?template_variation=publisher_fqdn::demo::ETH::Image::v1::variation::v1

If the call returns that the contract wasn't found, then the contract wasn't mined yet.

Sample error

{
    "error": 14,
    "message": "system::Error: 14, object not found: [contract not found]"
}

Once the contract is mined, something like this will be returned.

Sample Contract information

{
    "payload": {
        "template_variation": "publisher_fqdn::demo::ETH::Image::v1::variation::v1",
        "tx_hash": "0xf5a979b665241532f7152a5dd0186a28e279690d8d9b870ed0ca39d63d87bd8d",
        "vtemplate_address": "0xAC3B2515C5B26149d6E7D1f848B4cBFBECa7b334",
        "vtemplate_abi": "[{\"constant\":true,\"inputs\":[{\"name\":\"_interfaceID\",\"type\":\"bytes4\"}],\"name\":\"supportsInterface\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"name\",\"outputs\":[{\"name\":\"\",\"type\":\"string\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_tokenId\",\"type\":\"uint256\"}],\"name\":\"getApproved\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_to\",\"type\":\"address\"},{\"name\":\"_tokenId\",\"type\":\"uint256\"}],\"name\":\"approve\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"isAdminEnabled\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"totalSupply\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_from\",\"type\":\"address\"},{\"name\":\"_to\",\"type\":\"address\"},{\"name\":\"_tokenId\",\"type\":\"uint256\"}],\"name\":\"transferFrom\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_owner\",\"type\":\"address\"},{\"name\":\"_index\",\"type\":\"uint256\"}],\"name\":\"tokenOfOwnerByIndex\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_from\",\"type\":\"address\"},{\"name\":\"_to\",\"type\":\"address\"},{\"name\":\"_tokenId\",\"type\":\"uint256\"}],\"name\":\"safeTransferFrom\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_tokenId\",\"type\":\"uint256\"}],\"name\":\"exists\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_index\",\"type\":\"uint256\"}],\"name\":\"tokenByIndex\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_from\",\"type\":\"address\"},{\"name\":\"_to\",\"type\":\"address\"},{\"name\":\"_tokenId\",\"type\":\"uint256\"}],\"name\":\"approveFrom\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_from\",\"type\":\"address\"},{\"name\":\"_to\",\"type\":\"address\"},{\"name\":\"_approved\",\"type\":\"bool\"}],\"name\":\"setApprovalForAllFrom\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_tokenId\",\"type\":\"uint256\"}],\"name\":\"ownerOf\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"disableAdmin\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_owner\",\"type\":\"address\"}],\"name\":\"balanceOf\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"access\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"uri\",\"type\":\"string\"}],\"name\":\"setTokenBaseURI\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"symbol\",\"outputs\":[{\"name\":\"\",\"type\":\"string\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"vstorage\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_owner\",\"type\":\"address\"},{\"name\":\"_tokenId\",\"type\":\"uint256\"}],\"name\":\"burn\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_to\",\"type\":\"address\"},{\"name\":\"_approved\",\"type\":\"bool\"}],\"name\":\"setApprovalForAll\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"vtemplate\",\"type\":\"address\"}],\"name\":\"migrateVStorage\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_from\",\"type\":\"address\"},{\"name\":\"_to\",\"type\":\"address\"},{\"name\":\"_tokenId\",\"type\":\"uint256\"},{\"name\":\"_data\",\"type\":\"bytes\"}],\"name\":\"safeTransferFrom\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_from\",\"type\":\"address\"},{\"name\":\"_to\",\"type\":\"address\"},{\"name\":\"_tokenId\",\"type\":\"uint256\"}],\"name\":\"transfer\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_to\",\"type\":\"address\"},{\"name\":\"_tokens\",\"type\":\"uint256[]\"}],\"name\":\"emitN\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_tokenId\",\"type\":\"uint256\"}],\"name\":\"tokenURI\",\"outputs\":[{\"name\":\"\",\"type\":\"string\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_from\",\"type\":\"address\"},{\"name\":\"_to\",\"type\":\"address\"},{\"name\":\"_tokenId\",\"type\":\"uint256\"}],\"name\":\"_transferFrom\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"baseTokenURI\",\"outputs\":[{\"name\":\"\",\"type\":\"string\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_owner\",\"type\":\"address\"},{\"name\":\"_operator\",\"type\":\"address\"}],\"name\":\"isApprovedForAll\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_to\",\"type\":\"address\"},{\"name\":\"_tokenId\",\"type\":\"uint256\"}],\"name\":\"emit\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_tokenId\",\"type\":\"uint256\"},{\"name\":\"value\",\"type\":\"string\"}],\"name\":\"setHello\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"_from\",\"type\":\"address\"},{\"indexed\":true,\"name\":\"_to\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"_tokenId\",\"type\":\"uint256\"}],\"name\":\"Transfer\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"_owner\",\"type\":\"address\"},{\"indexed\":true,\"name\":\"_approved\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"_tokenId\",\"type\":\"uint256\"}],\"name\":\"Approval\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"_owner\",\"type\":\"address\"},{\"indexed\":true,\"name\":\"_operator\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"_approved\",\"type\":\"bool\"}],\"name\":\"ApprovalForAll\",\"type\":\"event\"}]",
        "vstorage_abi": "[{\"constant\":true,\"inputs\":[{\"name\":\"_tokenId\",\"type\":\"uint256\"}],\"name\":\"getHello\",\"outputs\":[{\"name\":\"\",\"type\":\"string\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_owner\",\"type\":\"address\"},{\"name\":\"_tokenId\",\"type\":\"uint256\"}],\"name\":\"emit\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_tokenId\",\"type\":\"uint256\"},{\"name\":\"value\",\"type\":\"string\"}],\"name\":\"setHello\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"}]",
        "fqdn": "publisher_fqdn",
        "network": "testnet",
        "from": "0xeed86f771959E9c595DA8eE8981317C91F3955b1"
    }
}

The contract address (vtemplate_address) can be used to lookup the contract and its transactions, for example on etherscan.io.

Emit a vAtom

The payload to emit a vAtom is the same as for off-chain vAtoms.

Emit vAtom

{
   "template_variation": "publisher_fqdn::demo::ETH::Image::v1::variation::v1",
   "num": 1
}

Reading the information on the blockchain

The smart contract information can be read using any smart contract explorer. This example will use ethersapp. We'll only read information, so no private key is needed. Use one of the following links:

This tutorial uses the Ropsten Test Network.

After clicking on + next to Contract, the Contract Address and Contract Api need to be filled in, they are the vtemplate_address and vtemplate_abi (without the escaped quotes) fields that were returned in the Getting the contract information. Contract Name is mandatory too, it will be used to show the smart contract in the drop-down menu. Clicking on Add will store the provided information and will then show the available functions of the contract.

ethersapp add contract

Sample vtemplate Contract Address

0xAC3B2515C5B26149d6E7D1f848B4cBFBECa7b334

Sample vtemplate ABI

[{"constant":true,"inputs":[{"name":"_interfaceID","type":"bytes4"}],"name":"supportsInterface","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"name","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_tokenId","type":"uint256"}],"name":"getApproved","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_tokenId","type":"uint256"}],"name":"approve","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"isAdminEnabled","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"totalSupply","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_from","type":"address"},{"name":"_to","type":"address"},{"name":"_tokenId","type":"uint256"}],"name":"transferFrom","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_owner","type":"address"},{"name":"_index","type":"uint256"}],"name":"tokenOfOwnerByIndex","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_from","type":"address"},{"name":"_to","type":"address"},{"name":"_tokenId","type":"uint256"}],"name":"safeTransferFrom","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_tokenId","type":"uint256"}],"name":"exists","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_index","type":"uint256"}],"name":"tokenByIndex","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_from","type":"address"},{"name":"_to","type":"address"},{"name":"_tokenId","type":"uint256"}],"name":"approveFrom","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_from","type":"address"},{"name":"_to","type":"address"},{"name":"_approved","type":"bool"}],"name":"setApprovalForAllFrom","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_tokenId","type":"uint256"}],"name":"ownerOf","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"disableAdmin","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_owner","type":"address"}],"name":"balanceOf","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"access","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"uri","type":"string"}],"name":"setTokenBaseURI","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"symbol","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"vstorage","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_owner","type":"address"},{"name":"_tokenId","type":"uint256"}],"name":"burn","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_approved","type":"bool"}],"name":"setApprovalForAll","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"vtemplate","type":"address"}],"name":"migrateVStorage","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_from","type":"address"},{"name":"_to","type":"address"},{"name":"_tokenId","type":"uint256"},{"name":"_data","type":"bytes"}],"name":"safeTransferFrom","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_from","type":"address"},{"name":"_to","type":"address"},{"name":"_tokenId","type":"uint256"}],"name":"transfer","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_tokens","type":"uint256[]"}],"name":"emitN","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_tokenId","type":"uint256"}],"name":"tokenURI","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_from","type":"address"},{"name":"_to","type":"address"},{"name":"_tokenId","type":"uint256"}],"name":"_transferFrom","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"baseTokenURI","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_owner","type":"address"},{"name":"_operator","type":"address"}],"name":"isApprovedForAll","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_tokenId","type":"uint256"}],"name":"emit","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_tokenId","type":"uint256"},{"name":"value","type":"string"}],"name":"setHello","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"inputs":[],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"name":"previousOwner","type":"address"},{"indexed":true,"name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_from","type":"address"},{"indexed":true,"name":"_to","type":"address"},{"indexed":false,"name":"_tokenId","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_owner","type":"address"},{"indexed":true,"name":"_approved","type":"address"},{"indexed":false,"name":"_tokenId","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_owner","type":"address"},{"indexed":true,"name":"_operator","type":"address"},{"indexed":false,"name":"_approved","type":"bool"}],"name":"ApprovalForAll","type":"event"}]

By clicking totalSupply on the left and then clicking Run, the total number of vAtoms for this template variation will be shown.

ethersapp total supply

Only one vAtom was emitted, so the total supply is 1.

Clicking tokenByIndex (with and index of 0) and clicking Run will return the ID of the first vAtom.

Sample vAtom ID

 38231985509680858236245480804139065952

The owners Ethereum address can be shown by clicking ownerOf and use the token ID from above.

Owner Address

0x5738af93631e6a3a17b0c4ba55bf939f42ec8467

Transfer vAtom

To be able to transfer the vAtom, the action has to be registered as described in creating your first vAtom. Once this is done, the vAtom can be transferred to another user.

API Reference: Perform Actions API

When an on-chain vAtom is transferred, the transfer of the ownership is recorded on the blockchain. Querying the owner of the emitted vAtom now shows the new owner.

New Owner Address

0x14b9ced955e68cfb9918d09035cfb72c8d4087cb

Reading fields

When the template was created it contained a section called fields. The values for each field can also be read as well, but they are stored via a second smart contract. Selecting vstorage from the drop-down will show the address. The ABI is also returned as part of the contract information. Fields in the Ethereum section can only be updated by reactors.

Sample vstorage Contract Address

0x7dde38b47bba5b4bf42db80902acd55977293b99

Sample vstorage ABI

[{"constant":true,"inputs":[{"name":"_tokenId","type":"uint256"}],"name":"getHello","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_owner","type":"address"},{"name":"_tokenId","type":"uint256"}],"name":"emit","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_tokenId","type":"uint256"},{"name":"value","type":"string"}],"name":"setHello","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"anonymous":false,"inputs":[{"indexed":true,"name":"previousOwner","type":"address"},{"indexed":true,"name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"}]

Using the previously collected information to add this smart contract as well, the Hello field can be read.

ethersapp read hello
©2020 BLOCKv
Info