This is PayFoot's ERC-20 smart contract, whose tokens are used as stablecoins in their ecosystem.
Note: Upon customer's request, the token smart contract does not include pausable token transfers, minting, and burning, and has no initial token supply.
See the created CHANGELOG
file in this repository.
We use the Truffle framework for the compilation, testing, and deployment. Please follow their guide to install the framework on your computer.
Run npm i
in order to install the necessary OpenZeppelin node modules as well as further required dependencies.
To compile the contract, it is important that you have installed the project correctly, as we use external dependencies and contracts. Use the following command to compile the contracts:
truffle compile
Since we build the ERC-20 smart contract on top of the audited OpenZeppelin node modules, there is no further requirement to write dedicated tests for these modules. Nonetheless, due to the fact that we integrate the non-standard permit
method, unit tests have been written for this specific extension.
You can run the tests with
npx hardhat test
Furthermore, if you need to test the permit
method on one of the live test networks, run the following command to generate the function parameters (assuming Node.js is installed):
node .\scripts\sign-data.js
To deploy the contract on your local Ganache blockchain, you must first install the software on your computer. Follow the installation guide.
Once you installed the local blockchain, you can create a workspace. This is described here.
Note: We have observed that Truffle and Ganache do not use the same default RPC configuration. The easiest way to align is to adjust Ganache's server hostname, port, and network ID with Truffle's configurations (check the file
truffle-config.js
).
Once you are setup, just run:
truffle migrate --network development
To deploy the smart contract to Rinkeby, you need to preconfigure first some things:
- Create a
secrets.json
file. - Create a MetaMask Wallet and paste the respective seedphrase into
secrets.json
. Make sure you got some ETH. You can get some here. - Create a new Infura project and copy the project key into
secrets.json
. - Create a Etherscan account and copy the API key to
secrets.json
. The file will look like the following (make sure to always.gitignore
it!):
{
"seedPhrase": "drip voice crush ...",
"privateKey": "0c7342ea3cdcc0...",
"owner": "0x3854Ca47Abc6...",
"projectId": "a657e3934de84d...",
"etherscanKey": "RQFAFV4DE1H75P..."
}
Now run the following command:
truffle migrate --network rinkeby
If the deployment was successful, you will get the final deployment result:
Copy the contract address and verify the contract right away so that you can interact with it. Run the following command:
truffle run verify PayFoot@<CONTRACTADDRESS> --network rinkeby
If the verification was successful, you will see a similar result as follows:
Verifying PayFoot@0x12bd590D921D3936Db75BA60FaAE1F6A2E495b46
Pass - Verified: https://rinkeby.etherscan.io/address/0x12bd590D921D3936Db75BA60FaAE1F6A2E495b46#contracts
Successfully verified 1 contract(s).
For more information, see here.
Note: The smart contract
PayFoot.sol
does include thepermit
method, which can be used to change an account's ERC20 allowance (seeIERC20.allowance
) by presenting a message signed by the account. By not relying onIERC20.approve
, the token holder account doesn't need to send a transaction, and thus is not required to hold Ether at all.
If you deployed the smart contract succefully, you are now able to interact with it.
To start the Truffle JavaScript console, please run:
truffle develop
In the console, you can create an instance of the provided contract by typing:
let i = await PayFoot.deployed()
You can use the instance variable to call functions like symbol:
i.symbol()
Go to the corresponding Etherscan link, e.g. https://rinkeby.etherscan.io/address/CONTRACTADDRESS#code. You are able to invoke READ and WRITE functions on the contract.
The smart contract PayFoot.sol
has been deployed across all the major test networks:
- Rinkeby: 0x12bd590D921D3936Db75BA60FaAE1F6A2E495b46
- Ropsten: 0xA7125fB628A2d4A60Cb650709ac046B5B2f9C12D
- Kovan: 0x667483ec1078c64f8D7e35B49152C3c2C87cCB56
- Goerli: 0x31e6Bf2c4E2Aa5AFC0e85b5feEF73C9137B24c5E
The smart contract PayFoot.sol
has been deployed to the PayFoot network with Remix* and signed with the PayFoot hardware wallet (Ledger Nano S):
- Contract creation transaction hash: 0x92e3aace3921e07d6a133f90ad1425ecc256ba5ad7a8964eeacf73d04407b9fc
- Contract address: 0x1C90008B345fA5BEf50d6AB617A1BB91cf51c41d
- Contract admin: 0x5D47fBF83EE223AfFA58fdd5EF61877c067c7390
- Contract Application Binary Interface (ABI): Can be downloaded from the snippet. This file was copied from Remix after compilation.
Note 1: Make sure that you always copy the full smart contract ABI and not just one of the inherited interfaces!
Note 2: Remix uses checksummed addresses for the
At Address
button and if it's invalid the button is disabled. Always use checksummed addresses with Remix! One way to handle this is by using EthSum. The checksum algorithm is laid out in full detail here.
* Remix deployment configuration:
- Compiler:
0.8.6+commit.11564f7e
; - Language:
Solidity
; - EVM Version:
compiler default
; - Enable optimization:
200
; - Only the smart contract
PayFoot.sol
was used for compilation and deployment. Remix imported the dependencies successfully (see here how this works in the background with the.deps
folder);
[1] https://docs.openzeppelin.com/contracts/4.x/erc20
[2] https://github.com/rkalis/truffle-plugin-verify