This project demonstrates a basic example of paying with ERC20 token using smart contract on Filecoin. This project includes a tokenPayment contract and frontend to interact with the tokenPayment Contract.
The first version of tokenPayment contract will accept wFIL ERC20 token as payment. Going forward, we are going to add more examples of accepting multiple erc20 tokens as payment or even token payment crossed from other chains.
In order to test the PoC, you will need to:
- clone this project and install all dependencies.
- add a
.env
file in the project which we will store wallet key and contract address for hardhat to use.- add the following lines in
.env
PRIVATE_KEY= WFIL_CONTRACT_ADDRESSS= PAYMENT_CONTRACT_ADDRESS=
- add the following lines in
- compile & deployed the tokenPayment contract and update
.env
file with token payment contract address.
There are two main features on the app.
-
Pay for service using wFIl.
-
For the admin(contract owner) to withdraw payments received in smart contract.
UI codes are all in frontend
folder, we need to install all the dependiecies in frontend
folder before we start the react app.
- Update the deployed
PAYMENT_CONTRACT_ADDRESS
infrontend/src/components/payToken.tsx
andfrontend/src/components/withdraw.tsx
. - If you changed the contract code, you also need to cope the generated
PaymentContract.json
over intofrontend/src/contracts/
folder. - You can start react app using
npm start
- Open http://localhost:3000 to view it in the browser.
Try running some of the following tasks:
npx hardhat help
npx hardhat test
REPORT_GAS=true npx hardhat test
npx hardhat node
npx hardhat ignition deploy ./ignition/modules/Lock.js
This is the v0 of token payment PoC. We will add more features including:
- Improve the UI/UX
- Accept multiple Filecoin-native ERC20 tokens as payment on Filecoin
- Link the payment to the service and track the payment history in smart contract
- Accept cross-chain token payment for storage service provided in other L1
- ......