-
-
Save hukamnonceblox/67566e9c0da8a12d9cef8911e1cc5024 to your computer and use it in GitHub Desktop.
matic bridge
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { use } = require("@maticnetwork/maticjs"); | |
const { Web3ClientPlugin } = require("@maticnetwork/maticjs-web3"); | |
const { FxPortalClient } = require("@fxportal/maticjs-fxportal"); | |
async function main() { | |
use(Web3ClientPlugin); | |
const fxPortalClient = new FxPortalClient(); | |
//fx client initiate | |
await fxPortalClient.init({ | |
network: 'testnet', | |
version: 'mumbai', | |
parent: { | |
provider: new HDWalletProvider(privateKey, rootRPC), | |
defaultConfig: { | |
from | |
} | |
}, | |
child: { | |
provider: new HDWalletProvider(privateKey, childRPC), | |
defaultConfig: { | |
from | |
} | |
} | |
}); | |
let erc20 = fxPortalClient.erc20("<tokenAddress>", "<isRoot>"); | |
//to approve | |
const approveResult = await erc20.approve("<amount>"); | |
//to deposit | |
const result = await erc20.deposit("<amount>", "<user address>"); | |
//to start withdraw | |
const result = await erc20.withdrawStart("<amount>"); | |
const txHash = await result.getTransactionHash(); | |
// withdraw exit | |
const result = await erc20.withdrawExit("<burn tx hash>"); | |
} | |
main() | |
.then(() => process.exit(0)) | |
.catch((error) => { | |
console.error(error); | |
process.exit(1); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment