@waveshq/state-relayer-bot
v0.0.3
Published
A project comprising of smart contracts and scripts to port certain information from DeFiChain to DeFiMetaChain
Downloads
3
Readme
DeFiChain <-> DeFiMetaChain State Relayer
A project comprising of smart contracts and scripts to port certain information from DeFiChain to DeFiMetaChain
Directory Structure
├── bot // <-- Logic for the bot + integration test
├── contracts // <- The smart contracts + example solidity usage
├── scripts // <- Deployment scripts + gas estimation
├── tests // <- Smart contract tests
├── containers // <- Containers for integration tests
How to use the package to update information on DeFiMetaChain
import {handler} from "@waveshq/state-relayer-bot";
import { EnvironmentNetwork } from "@waveshq/walletkit-core"
handler({
testGasCost: false,
urlNetwork: "https://ocean.defichain.com/",
envNetwork: EnvironmentNetwork.MainNet,
contractAddress: /* YOUR STATE RELAYER PROXY ADDRESS */,
signer: /* signer object */,
gasUpdateDEX: /* gas limit for dex update transaction */,
gasUpdateMaster: /* gas limit for master node update transaction */,
gasUpdateVault: /* gas limit for vault update transaction */
})
Instruction to consume the smart contract information
Examples on how to consume the information exposed by the smart contract is showcased via this folder and this folder
How to deploy your smart contract on DMCTestnet
Install the dependencies and compile smart contracts:
npm ci
npx hardhat compile
- If you use .env file, just execute this:
npx hardhat run --network DMCTestnet scripts/deployment.ts
- If you want to use Ledger, comment the accounts line and uncomment the ledgerAccounts line under DMCTestnet section. Execute this command:
npx hardhat run --network DMCTestnet scripts/deployment.ts
How to manage permission for smart contracts via Metamask
There are three main functions related to this:
grantRole(bytes32,address)
, revokeRole(bytes32,address)
and renounceRole(bytes32,address)
Clone the repo.
git checkout v0.0.1, (the version that the smart contract is deployed from)
Install dependencies and compile smart contract:
npm ci
npx hardhat compile
Copy file scripts/utils/generateEncodedData.ts from main onto this branch (v0.0.1) and then generate encoded data by executing this command line:
npx ts-node scripts/utils/generateEncodedData
After this, enable metamask to be able to show hex data.
Then when creating a transaction to send, enter the smart contract address as the recipient, then paste the generated encoded data into the "Hex data" field.
A similar flow is showcased in video/MetamaskInstruction.mov
Smart contract addresses deployed by BirthdayResearch team
MetaChain Mainnet
StateRelayerProxy: 0xa075dC93D00ac14f4a7416C03cAbec4728586760
StateRelayer: 0x970F740feB2D14926881d51873Eb81E9183E7B18
MetaChain Testnet
StateRelayerProxy: 0xA6A853DDbfB6C85d3584E33313628555BA85753B
StateRelayer: 0x45f94FFE3fE1b1076e145285E11D5E7Cdf7d6f5e