hyperledger / firefly-tokens-erc20-erc721

ERC20 and ERC721 token integration
https://github.com/hyperledger/firefly-tokens-erc20-erc721
Apache License 2.0
20 stars 22 forks source link

Add "Getting Started" Docs to repo #39

Open dechdev opened 2 years ago

jimthematrix commented 2 years ago
  1. install the latest FireFly CLI:

    $ go install github.com/hyperledger/firefly-cli/ff@latest
  2. initialize the FireFly stack using Ethereum as the underlying blockchain, and load the ERC20/ERC721 token connector:

    $ ff init -t erc20_erc721
  3. start the stack named "digital-assets"

    $ ff start digital-assets
  4. deploy the token contract. the easiest way is using Truffle. The Hyperledger implementation of the token connector has sample ERC20 and ERC721 contracts you can use to deploy to Ethereum:

    $ git clone git@github.com:hyperledger/firefly-tokens-erc20-erc721.git
    $ cd firefly-tokens-erc20-erc721
    $ cd solidity
    $ npm install
    $ truffle migrate
  5. copy the contract address for the deployed ERC20 token contract (highlighted below in the sample output), to use in the next step

    
    Starting migrations...
    ======================
    > Network name:    'development'
    > Network id:      2021
    > Block gas limit: 4722986 (0x48112a)

1_initial_migration.js

Deploying 'Migrations'

⠋ Blocks: 0 Seconds: 0 > transaction hash: 0xb81c60fd920bf28775bd8610271c60a40380e278af97ccd18458efafe852dc99

Blocks: 0 Seconds: 0 contract address: 0x0C2c9222835692912b3999D6DAE955a9d306393d block number: 6 block timestamp: 1648585628 account: 0x1eAecAb9D796Ee765865f47a78De13735619c914 balance: 904625697166532776746648320380374280103671755200316906558.262375061821325312 gas used: 272788 (0x42994) gas price: 0 gwei value sent: 0 ETH total cost: 0 ETH

Saving migration to chain. Saving artifacts

Total cost: 0 ETH

2_deploy_contracts.js

Deploying 'ERC20WithData'

⠋ Blocks: 0 Seconds: 0 > transaction hash: 0x748a60953ceacda47431210752c2a9991f77b552d19397827500feef086fc3cf

Blocks: 0 Seconds: 0 contract address: 0xB6728020f998f32afb4936f9CEcE04B1d3951895 block number: 8 block timestamp: 1648585628 account: 0x1eAecAb9D796Ee765865f47a78De13735619c914 balance: 904625697166532776746648320380374280103671755200316906558.262375061821325312 gas used: 1948804 (0x1dbc84) gas price: 0 gwei value sent: 0 ETH total cost: 0 ETH

Saving migration to chain. Saving artifacts

Total cost: 0 ETH

Summary

Total deployments: 2 Final cost: 0 ETH

  1. teach FireFly about the token contract so that it can start tracking transactions on the contract. For this step you can use the Swagger UI that comes with FireFly. Open http://localhost:5000/api, and expand the request entry POST /namespaces/{ns}/tokens/pools. Plugin the values as shown below (you can delete all the other optional properties in the payload):

image

  1. Now you can start using FireFly APIs to manage the new token contract: mint/transfer/burn.

  2. You can use the following JSON RPC command to create additional Ethereum addresses in the go-ethereum node's built-in wallet:

    
    $ curl -H 'Content-Type: application/json' -d '{"jsonrpc":"2.0","id":"1","method":"personal_newAccount","params":["passw0rd"]}' http://localhost:5100 | jq
    {
    "jsonrpc": "2.0",
    "id": "1",
    "result": "0xfd5d5d96879a700c693da5092e2a6ef5ed399684"
    }

$ curl -H 'Content-Type: application/json' -d '{"jsonrpc":"2.0","id":"1","method":"personal_unlockAccount","params":["0xfd5d5d96879a700c693da5092e2a6ef5ed399684","passw0rd",0]}' http://localhost:5100 |jq { "jsonrpc": "2.0", "id": "1", "result": true }



10. Try the minting API using the POST /namespaces/{ns}/tokens/mint endpoint:

![image](https://user-images.githubusercontent.com/5289853/161083896-f68a8c9d-aede-4580-b35f-228e82dafd2a.png)

11. check the result of the minting transaction in the FireFly UI at [http://localhost:5000/ui](http://localhost:5000/ui) (for org0) and [http//localhost:5001/ui](http//localhost:5001/ui) (for org1):

![image](https://user-images.githubusercontent.com/5289853/161084052-051fa144-9b56-4f14-bdea-43802398b031.png)

12. Connect metamask (to be continued)