| .. | ||
| README.md | ||
| stack.yml | ||
ERC721 Watcher
Instructions to deploy a local ERC721 watcher stack (core + watcher) for demonstration and testing purposes using laconic-stack-orchestrator
Setup
- Clone / pull required repositories:
laconic-so --stack erc721 setup-repositories
- Build the core and watcher container images:
laconic-so --stack erc721 build-containers
This should create the required docker images in the local image registry.
- Deploy the stack:
laconic-so --stack erc721 deploy-system up
Demo
-
Find the watcher container's id using
docker psand export it for later use:$ export CONTAINER_ID=<CONTAINER_ID> -
Deploy an ERC721 token:
$ docker exec $CONTAINER_ID yarn nft:deploy:dockerExport the address of the deployed token to a shell variable for later use:
$ export NFT_ADDRESS=<NFT_ADDRESS> -
Open
http://localhost:3009/graphql(GraphQL Playground) in a browser window -
Connect MetaMask to
http://localhost:8545(with chain ID99) -
Export your MetaMask account (second account) address to a shell variable for later use:
$ export RECIPIENT_ADDRESS=<RECIPIENT_ADDRESS> -
To get the primary account's address, run:
$ docker exec $CONTAINER_ID yarn account:dockerExport it to shell variable for later use:
$ export PRIMARY_ADDRESS=<PRIMARY_ADDRESS> -
To get the current block hash at any time, run:
$ docker exec $CONTAINER_ID yarn block:latest:docker -
Fire the following GQL query (uses
eth_call) in the playground:query { name( blockHash: "LATEST_BLOCK_HASH" contractAddress: "NFT_ADDRESS" ) { value proof { data } } symbol( blockHash: "LATEST_BLOCK_HASH" contractAddress: "NFT_ADDRESS" ) { value proof { data } } balanceOf( blockHash: "LATEST_BLOCK_HASH" contractAddress: "NFT_ADDRESS" owner: "PRIMARY_ADDRESS" ) { value proof { data } } }Balance for the
PRIMARY_ADDRESSshould be0as the token is yet to be minted. -
Fire the following GQL query (uses
storagecalls) in the playground:query { _name( blockHash: "LATEST_BLOCK_HASH" contractAddress: "NFT_ADDRESS" ) { value proof { data } } _symbol( blockHash: "LATEST_BLOCK_HASH" contractAddress: "NFT_ADDRESS" ) { value proof { data } } _balances( blockHash: "LATEST_BLOCK_HASH" contractAddress: "NFT_ADDRESS" key0: "PRIMARY_ADDRESS" ) { value proof { data } } } -
Mint the token:
$ docker exec $CONTAINER_ID yarn nft:mint:docker --nft $NFT_ADDRESS --to $PRIMARY_ADDRESS --token-id 1Fire the GQL query above again with latest block hash. The balance should increase to
1. -
Get the latest block hash and run the following GQL query in the playground for
balanceOfandownerOf(eth_call):query { fromBalanceOf: balanceOf( blockHash: "LATEST_BLOCK_HASH" contractAddress: "NFT_ADDRESS" owner: "PRIMARY_ADDRESS" ) { value proof { data } } toBalanceOf: balanceOf( blockHash: "LATEST_BLOCK_HASH" contractAddress: "NFT_ADDRESS" owner: "RECIPIENT_ADDRESS" ) { value proof { data } } ownerOf( blockHash: "LATEST_BLOCK_HASH" contractAddress: "NFT_ADDRESS" tokenId: 1 ) { value proof { data } } }Balance should be
1for thePRIMARY_ADDRESS,0for theRECIPIENT_ADDRESSand owner value of the token should be equal to thePRIMARY_ADDRESS. -
Transfer the token:
$ docker exec $CONTAINER_ID yarn nft:transfer:docker --nft $NFT_ADDRESS --from $PRIMARY_ADDRESS --to $RECIPIENT_ADDRESS --token-id 1Fire the GQL query above again with the latest block hash. The token should be transferred to the recipient.
Clean up
- To stop all the services running in background:
laconic-so --stack erc721 deploy-system down