Last active
June 29, 2021 05:39
-
-
Save heri16/cd383f19ffec5e6b8abf323391697042 to your computer and use it in GitHub Desktop.
Trigger Polygon / MATIC Token Bridge via ethers.js
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
// See: https://github.com/maticnetwork/matic.js/blob/master/examples/POS-client/config.js | |
const posRootChainManager = '0xBbD7cBFA79faee899Eaf900F13C9065bF03B1A74'; | |
const posERC20Predicate = '0xdD6596F2029e6233DEFfaCa316e6A95217d4Dc34'; | |
const accounts = useAccounts(); | |
const userAddress = accounts?.[0] | |
const rootDaiContract = useContractContext(DAIDummyContext, 0); | |
const { send: approve } = useContractFunc(rootDaiContract, "approve"); | |
await approve(posERC20Predicate, amount); | |
const rootChainManagerContract = rootChainManagerContract__factory.connect(posRootChainManager, rootDaiContract.signer); | |
const { send: depositFor } = useContractFunc(rootChainManagerContract, "depositFor"); | |
const depositData = ethers.utils.defaultAbiCoder.encode(['uint256'], [amount]); | |
await depositFor(userAddress, rootDaiContract.address, depositData); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment