Skip to content

codechef924/fabric-contract-erc20

Repository files navigation

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

transfer success!


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

Releases

No releases published

Packages

No packages published

Languages