ERC-20

Deploying ERC20 contract manually

If you need to deploy the ERC20 contract manually you will need to pass some parameters.

The following command is a template to deploy the ERC20 contract:

sudo casper-client put-deploy \
    --chain-name chain_name \
    --node-address http://$NODE_ADDRESS:7777/ \
    --secret-key path_to_secret_key.pem \
    --session-path path_to_wasm_file \
    --payment-amount 10000000000 \
    --session-arg="public_key:public_key='Public Key In Hex'" \
    --session-arg="name:string='token-name'" \
    --session-arg="symbol:string='token-symbol'" \
    --session-arg="decimals:u8='unsigned integer value'" \
    --session-arg="initial_supply:u256='unsigned integer value'" \
    --session-arg="contract_name:string='contract_name'"

Entry point methods

ERC20's entry point methods are detailed below:

transfer

Allows self.get_caller() to send pool tokens to a recipient hash.

Parameters table:

Parameter Name
Type

recipient

Key

amount

U256

This method returns nothing.

transfer_from

Sends pool tokens from one hash to another.

The user has to call the approve method before calling tranfer_from.

Parameters table:

Parameter Name
Type

owner

Key

recipient

Key

amount

U256

This method returns nothing.

Recommendation:

Possible exploits should be taken into account.

Using functions that increase/decrease the allowance relative to its current value is highly encouraged.

We strongly recommend developers of applications dependant on approve() / transferFrom() to set allowance to 0 first and verify if it was used before setting a new value.

Note: Teams who decide to rely on this standard should forward these recommendations to app developers implementing their token contract.

permit

Sets the allowance for a spender in scenarios where approval is granted via a signature.

Parameters table

Parameter Name
Type

public

String

signature

String

owner

Key

spender

Key

value

U256

deadline

u64

This method returns nothing.

approve

Allows self.get_caller() to set allowance for a spender. The user has to call this method before calling the transfer_from method.

Parameters table:

Parameter Name
Type

spender

Key

amount

U256

This method returns nothing.

Recommendation:

Possible exploits should be taken into account.

Using functions that increase/decrease the allowance relative to its current value is highly encouraged.

We strongly recommend developers of applications dependant on approve() / transferFrom() to set allowance to 0 first and verify if it was used before setting a new value.

Note: Teams who decide to rely on this standard should forward these recommendations to app developers implementing their token contract.

balance_of

Returns the owner's balance in ERC20 Contracts.

Parameters table:

Parameter Name
Type

owner

Key

This method returns an U256.

nonce

Returns the current nonce of an address for use in permit.

Parameters table

Parameter Name
Type

owner

Key

This method returns an U256.

allowance

Returns the amount of liquidity tokens owned by a hash that a spender is allowed to transfer via transfer_from.

Parameters table:

Parameter Name
Type

owner

Key

spender

Key

This method returns an U256.

total_supply

Returns the total amount of pool tokens for a pair.

Parameters table

This method returns an U256.

mint

Mints a number of tokens provided by the user against the hash provided by the user.

Parameters table

Parameter Name
Type

to

Key

amount

U256

This method returns nothing.

burn

Burns a number of tokens provided by user against the hash provided by user.

Parameters table:

Parameter Name
Type

from

Key

amount

U256

This method returns nothing.

Note: In order to burntokens against the hash provided by user, User needs to mint them in ERC20 first.

name

Returns the tokens name for a pair.

Parameters table:

This method returns a String.

symbol

Returns the tokens symbol for a pair.

Parameters table:

This method returns a String.

Last updated