The general concept isn't new and on the Internet, it is possible to find many examples of non-custodial smart contracts. Problem is that they are usually in an old version of Solidity and they were made before ERC1167.
Our idea is based on the CoinBase blog post, but with a few fundamental changes.
First of all, the core of this idea is based on market standards. We took contracts and libraries from OpenZeppelin to ensure that we are not duplicating anything that we don’t have to.
The second thing is that the Forwarder smart contract in the blog post is prepared only for tokens, and initialization is based on a constructor that isn’t currently recommended.
The last thing is that our all concept is developed in Solidity 0.8.0, which implies the next positive changes.
To have better understanding of the conncept, please read
NPM - dependency management
Truffle - project structure and cli management
OpenZeppelin - verified market standards
Ganache - for local tests
There are a few technical requirements before you start. Please install the following:
When you will have all tools installed, please remember about running npm install
in the project root catalog.
Detailed dependent libraries you will find in package.json
If you don't have any IDE, VSCode is simple, free, and good enough to project like this.
Truffle configuration file is prepared for local run - truffle-config.js
The full command reference is available here
Basic examples:
Compilation: truffle compile
Deployment/Migration: truffle migrate --network development
Run all local tests: truffle test
Run selected local tests: truffle test test/[FILENAME]
For external verification we will use infura and Ropsten network.
-
Make a copy of
.example.secrets.json' with name
.secrets.json` in the same catalog -
Install Metamask at your local computer
-
Add some funds to the address in metamask using Ropsten faucet (https://faucet.ropsten.be/)
-
Copy mnemonic to variable MNEMONIC in `.secrets.json'
-
Create an account at https://infura.io/
-
Create a new project there and save project ID
-
Fill PROJECT_ID in
.secrets.json
with the value saved in INFURA -
Deploy the project using the command
truffle migrate --network ropsten
-
Save deployed smart contract addresses
-
Go to catalog
test/client
-
Run
npm install
-
Make a copy of
.example.netfonig.json
with the name.netconfig.json
in the same catalog -
Fill all fields in the configuration file
-
Initialize forwarder smart contract with command
npm run init_test
-
To check factory methods run the command
npm run factory_test