Code Monkey home page Code Monkey logo

fabric-contract-erc20's Introduction

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

fabric-contract-erc20's People

Contributors

codechef924 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.