This repository contains a treasury developed based on the functionality of ckERC20 within the ICP blockchain ecosystem. This technology utilizes HTTP outcalls to query multiple JSON-RPC providers to interact with the BSC Testnet blockchain.
BSC Testnet addresses:
| Name | Address |
|---|---|
| Minter | 0x7187CC02Be5f744eE15653A4ea3F13FeC23E1a7B |
| Token | 0x890e77bA80f1D3f62Fe5d9259750f0C52F198b0f |
| Deposit | 0xaDc4434fD98D5dA23Bc0DCd6C281BBE2E021D7c1 |
ICP addresses:
| Name | Principal |
|---|---|
| Minter | be2us-64aaa-aaaaa-qaabq-cai |
The Eden Treasury is responsible for depositing and withdrawing the ERC-20 token. Each deposit involves invoking the deposit method on the smart contract (CkErc20Deposit) on the BSC Testnet network.
- Depositing tokens into the smart contract triggers the emission of the "ReceivedErc20" event, which contains all the information related to the deposit.
- The Eden Treasury periodically reads the latest events from the CkErc20Deposit contract and subsequently credits the transferred tokens to the recipient's account.
Flow:
ββββββ βββββββββββββββββ βββββββββββββββββ ββββββββ βUserβ βERC-20 Contractβ βHelper Contractβ βVault β βββ¬βββ βββββββββ¬ββββββββ βββββββββ¬ββββββββ ββββ¬ββββ β β β β βapprove(helper_contract, amount) β β β βββββββββββββββββββββββββββββββββ>β β β β β β β β deposit(amount, principal) β β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ>β β β β transferFrom(user, minter, amount) β β β β<βββββββββββββββββββββββββββββββββββββ β β β β β β β β get_events β β β β<βββββββββββββββββββββββββββββββββββ β β βEvents(token_id, amount, principal)β β β βββββββββββββββββββββββββββββββββββ>β β β asign_tokens(amount, principal) β β β<βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ βββ΄βββ βββββββββ΄ββββββββ βββββββββ΄ββββββββ ββββ΄ββββ βUserβ βERC-20 Contractβ βHelper Contractβ βVault | ββββββ βββββββββββββββββ βββββββββββββββββ ββββββββ
- Calling the "withdraw_erc20" method results in the tokens being deducted from the treasury and a transaction being created and sent. If the transaction fails, it is resent.
ββββββ ββββββββ βββββββββββββββββββββ βUserβ βVault β βBSC Testnet Networkβ βββ¬βββ ββββ¬ββββ βββββββ¬ββββββββββββββ β β β β withdraw_erc20(amount, destination_eth_address) β β βββββββββββββββββββββββββββββββββββββββββββββββββββββββ>β β β β eth_sendRawTransaction β β β (destination_eth_address, amount) β β ββββββββββββββββββββββββββββββββββββββββ>β βββ΄βββ ββββ΄ββββ βββββββ΄ββββββββββββββ βUserβ βVault β βBSC Testnet Networkβ ββββββ ββββββββ βββββββββββββββββββββ
If you want to start working on your project right away, you might want to try the following commands:
cd eden_vault/
dfx help
dfx canister --helpIf you want to test your project locally, you can use the following commands:
# Starts the replica, running in the background
dfx start --background
# Deploys your canisters to the replica and generates your candid interface
dfx deployOnce the job completes, your application will be available at http://localhost:4943?canisterId={asset_canister_id}.
If you have made changes to your backend canister, you can generate a new candid interface with
npm run generateat any time. This is recommended before starting the frontend development server, and will be run automatically any time you run dfx deploy.
If you are making frontend changes, you can start a development server with
npm startWhich will start a server at http://localhost:8080, proxying API requests to the replica at port 4943.