Sample ERC20 token implementation with Hyperledger Fabric chaincode (Golang)
This is the Golang chaincode version of Ethereum's ERC20 token standard
based OpenZeppelin's implementation
Basic features:
- Basic Token
- Ownable Token
- Detailed Token
- Mintable Token
- Burnable Token
- Pausable Token
Custom feature:
- Transaction memo - able to attach an 'memo' to a transaction with a extra parameter to
Transfer
or TransferFrom
methods
- Unregistered account check - accounts that are not registered can not do transactions, register them first with
Activate
chaincode method
Demo
Set up the network via development tool (Hurley) or manual set up via the official document
Install & instantiate the chaincode on the network
chaincodes are placed inside a separated Docker container
total supply of tokens are equal to the miner's (chaincode caller) account
try to transfer some tokens to another account --> error due to the target user is not 'activated'
'activate' said account
![](https://github.com/dungtang93/fabric-erc20-go/raw/d8468afafbb4/readme/6.png)
transfer
success!
![](https://github.com/dungtang93/fabric-erc20-go/raw/d8468afafbb4/readme/7.png)
Offline Unit Testing
Manually apply this patch for ABAC testing with mockStub (change line 69 & 361 like the patch in file loyalty-token-hf\hlt\go_workspace\src\github.com\hyperledger\fabric\core\chaincode\shim\mockstub.go
), after you've installed Go chaincode libraries of course
Get Ginkgo test framework
go get github.com/onsi/ginkgo/ginkgo
go get github.com/onsi/gomega/...
Execute go test -v
to run the test suites without the need to start up the block chain
For details please read into sample_token.go