https://github.com/gcp-development/erc20
ERC-20 Token Standard
https://github.com/gcp-development/erc20
polkadot rust smart-contracts wasm webassembly
Last synced: about 2 months ago
JSON representation
ERC-20 Token Standard
- Host: GitHub
- URL: https://github.com/gcp-development/erc20
- Owner: gcp-development
- Created: 2022-11-04T11:31:24.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-06-02T15:17:14.000Z (about 3 years ago)
- Last Synced: 2025-03-26T11:32:14.030Z (about 1 year ago)
- Topics: polkadot, rust, smart-contracts, wasm, webassembly
- Language: Rust
- Homepage:
- Size: 70.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# erc20
ERC-20 Token Standard
It's assumed that these software are installed and running:
This project was developed using the [Intellij Community](https://www.jetbrains.com/idea/download/#section=linux) with the [Rust plugin](https://www.jetbrains.com/rust/).
## Table of Contents
- [Environment](https://github.com/gcp-development/erc20/blob/main/README.md#environment)
- [Test cases](https://github.com/gcp-development/erc20/blob/main/README.md#test-cases)
- [Create an account](https://github.com/gcp-development/erc20/blob/main/README.md#create-an-account)
- [Build](https://github.com/gcp-development/erc20/blob/main/README.md#build)
- [Deploy via command-line](https://github.com/gcp-development/erc20/blob/main/README.md#deploy-via-command-line)
- [Deploy via browser](https://github.com/gcp-development/erc20/blob/main/README.md#deploy-via-browser)
### Environment
[ink! CLI version](https://use.ink/getting-started/setup#ink-cli).
```bash
cargo contract --version
```

The current [toolchain](https://rust-lang.github.io/rustup-components-history/) setup is as follows:
```bash
rustup toolchain install nightly-2023-02-09
```
```bash
rustup component add rust-src --toolchain nightly-2023-02-09-x86_64-unknown-linux-gnu
```
```bash
rustup override set nightly-2023-02-09
```
Note: There is a current [bug](https://github.com/paritytech/cargo-contract/issues/1058) in cargo-contract, building contracts with rust nightly 1.70.0 or higher. That's why we have to use the rustc [v1.69.0](https://blog.rust-lang.org/2023/04/20/Rust-1.69.0.html).
The directory will be assigned with a Rust toolchain with [rustup override](https://rust-lang.github.io/rustup/overrides.html#directory-overrides).
```bash
rustup show
```

Note:The nightly-2023-02-09 is set by the [rust-toolchain.toml](https://github.com/gcp-development/erc20/blob/main/rust-toolchain.toml) file.
### Test cases
Run the test cases for the contract
```bash
cargo test
```

### Build
Build the contract
```bash
cargo contract build
```

In the target folder we should have these files:
```bash
target
└─ ink
└─ erc20.contract
└─ erc20.wasm
└─ metadata.json
```
A Wasm binary(erc20.wasm), a metadata file (metadata.json/which contains the contract's [ABI](https://use.ink/basics/metadata#abi)) and the contract file(erc20.contract/which we will deploy to our chain).

### Create an account
Create an [Polkdot account](https://wiki.polkadot.network/docs/learn-account-generation#polkadot-js-browser-extension).

Note:For this example the [firefox polkadot-js-extension](https://addons.mozilla.org/en-GB/firefox/addon/polkadot-js-extension/) was used.
### Deploy via command-line
Deploy the contract.
```bash
cargo contract upload --suri "account twelve words"
```
Instantiate the contract.
```bash
cargo contract instantiate --suri … --constructor new --args 1
```
Note:cargo-contract [commands](https://github.com/paritytech/cargo-contract/blob/master/docs/extrinsics.md#commands)
### Deploy via browser
Deploy the contract to [Rococo](https://polkadot.js.org/apps/?rpc=wss%3A%2F%2Frococo-contracts-rpc.polkadot.io#/contracts)([testnet](https://use.ink/testnet) for Polkadot)





References:
[ink!](https://use.ink/4.0.0-alpha.1/)
[Rust and WebAssembly](https://rustwasm.github.io/docs/book/)