https://github.com/tcd93/fabric-erc20-go
Hyperledger Fabric Golang Chaincode implementation of ERC20 token
https://github.com/tcd93/fabric-erc20-go
erc20 erc20-tokens golang golang-chaincode hyperledger-fabric-chaincode smart-contract
Last synced: 8 months ago
JSON representation
Hyperledger Fabric Golang Chaincode implementation of ERC20 token
- Host: GitHub
- URL: https://github.com/tcd93/fabric-erc20-go
- Owner: tcd93
- License: mit
- Created: 2019-12-30T08:44:53.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2020-04-07T06:02:26.000Z (over 5 years ago)
- Last Synced: 2024-06-21T18:56:07.636Z (over 1 year ago)
- Topics: erc20, erc20-tokens, golang, golang-chaincode, hyperledger-fabric-chaincode, smart-contract
- Language: Go
- Homepage:
- Size: 175 KB
- Stars: 9
- Watchers: 1
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Sample ERC20 token implementation with Hyperledger Fabric chaincode (Golang)
This is the Golang chaincode version of [Ethereum's ERC20 token standard](https://eips.ethereum.org/EIPS/eip-20)
based [OpenZeppelin's implementation](https://github.com/OpenZeppelin/openzeppelin-contracts/blob/9b3710465583284b8c4c5d2245749246bb2e0094/contracts/token/ERC20/ERC20.sol)_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](https://github.com/worldsibu/hurley)) or manual set up via the [official document](https://hyperledger-fabric.readthedocs.io/en/release-1.4/dev-setup/devenv.html)[Install & instantiate the chaincode](https://hyperledger-fabric.readthedocs.io/en/release-1.4/chaincode4noah.html#installing-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](https://gerrit.hyperledger.org/r/c/fabric/+/28744/2/core/chaincode/shim/mockstub.go#361) (_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 courseGet [Ginkgo test framework](https://onsi.github.io/ginkgo/)
```
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`