sample scripts updated
MODIFY
examples/POS-client/ERC1155/burnSingle.js
examples/POS-client/ERC1155/burnSingle.js
@@ -4,11 +4,13 @@ const maticPOSClient = utils.getMaticPOSClient()
const execute = async () => {
try {
- const tx = await maticPOSClient.burnSingleERC1155(config.child.DERC1155, config.user.tokenId, config.user.amount)
- console.log(tx.transactionHash) // eslint-disable-line
+ const tx = await maticPOSClient.isSingleERC1155ExitProcessed(
+ '0xbfc70c164f6951d9c9f3f87f2d1361ff216eb3d6fe9571430bd3f0711847a782'
+ )
+
+ console.log(tx) // eslint-disable-line
} catch (e) {
console.error(e) // eslint-disable-line
}
}
-
execute().then(() => process.exit(0))

MODIFY
examples/POS-client/ERC1155/depositSingle.js
examples/POS-client/ERC1155/depositSingle.js
@@ -7,8 +7,14 @@ const execute = async () => {
const tx = await maticPOSClient.depositSingleERC1155ForUser(
config.root.DERC1155,
config.user.address,
- config.user.tokenId,
- config.user.amount
+ '123',
+ '1',
+ [],
+ {
+ from: config.user.address,
+ gasPrice: '900000000000',
+ gas: '550000',
+ }
)
console.log(tx.transactionHash) // eslint-disable-line
} catch (e) {

MODIFY
examples/POS-client/ERC20/approve.js
examples/POS-client/ERC20/approve.js
@@ -4,11 +4,15 @@ const maticPOSClient = utils.getMaticPOSClient()
const execute = async () => {
try {
- const tx = await maticPOSClient.approveERC20ForDeposit(config.root.DERC20, config.user.amount)
- console.log(tx.transactionHash) // eslint-disable-line
+ const tx = await maticPOSClient.approveERC20ForDeposit(config.root.DERC20, config.user.amount, {
+ from: config.user.address,
+ gasPrice: '900000000000',
+ gas: '250000',
+ })
+
+ console.log(tx) // eslint-disable-line
} catch (e) {
console.error(e) // eslint-disable-line
}
}
-
execute().then(() => process.exit(0))

MODIFY
examples/POS-client/ERC20/burn.js
examples/POS-client/ERC20/burn.js
@@ -4,8 +4,12 @@ const maticPOSClient = utils.getMaticPOSClient()
const execute = async () => {
try {
- const tx = await maticPOSClient.burnERC20(config.child.DERC20, config.user.amount)
- console.log(tx.transactionHash) // eslint-disable-line
+ const tx = await maticPOSClient.burnERC20(config.child.DERC20, config.user.amount, {
+ from: config.user.address,
+ gasPrice: 900000000000,
+ gas: 300000,
+ })
+ console.log(tx) // eslint-disable-line
} catch (e) {
console.error(e) // eslint-disable-line
}

MODIFY
examples/POS-client/ERC20/exit.js
examples/POS-client/ERC20/exit.js
const utils = require('../utils')
const maticPOSClient = utils.getMaticPOSClient()
+const config = require('../config')
const burnHash = '0xbadbf10a33ba5ae48cfa1660e011eb15bf927773610ace9466c71d14749d4132'
const execute = async () => {
try {
- const tx = await maticPOSClient.exitERC20(burnHash)
+ const tx = await maticPOSClient.exitERC20(burnHash, {
+ from: config.user.address,
+ gasPrice: 900000000000,
+ gas: 400000,
+ })
console.log(tx.transactionHash) // eslint-disable-line
} catch (e) {
console.error(e) // eslint-disable-line
}
}
-
execute().then(() => process.exit(0))

MODIFY
examples/POS-client/ERC721/approve.js
examples/POS-client/ERC721/approve.js
@@ -4,11 +4,14 @@ const maticPOSClient = utils.getMaticPOSClient()
const execute = async () => {
try {
- const tx = await maticPOSClient.approveERC721ForDeposit(config.root.DERC721, config.user.tokenId)
+ const tx = await maticPOSClient.approveERC20TokensForDeposit(config.root.DERC20, config.user.amount, {
+ from: config.user.address,
+ gasPrice: '500000000000',
+ gas: 2500000,
+ })
console.log(tx.transactionHash) // eslint-disable-line
} catch (e) {
console.error(e) // eslint-disable-line
}
}
-
execute().then(() => process.exit(0))

MODIFY
examples/POS-client/config.js
examples/POS-client/config.js
module.exports = {
root: {
- RPC: '<GOERLI_RPC>',
- RootChainManagerProxy: '0xBbD7cBFA79faee899Eaf900F13C9065bF03B1A74',
- DERC20: '0x655F2166b0709cd575202630952D71E2bB0d61Af',
- DERC721: '0x084297B12F204Adb74c689be08302FA3f12dB8A7',
+ RPC: '<goerli RPC>',
+ POSRootChainManager: '0xBbD7cBFA79faee899Eaf900F13C9065bF03B1A74',
+ DERC20: '0x655f2166b0709cd575202630952d71e2bb0d61af',
+ DERC721: '0x5a08d01e07714146747950CE07BB0f741445D1b8',
DERC1155: '0x2e3Ef7931F2d0e4a7da3dea950FF3F19269d9063',
posERC20Predicate: '0xdD6596F2029e6233DEFfaCa316e6A95217d4Dc34',
posERC721Predicate: '0x74D83801586E9D3C4dc45FfCD30B54eA9C88cf9b',
@@ -12,17 +12,17 @@ module.exports = {
},
child: {
RPC: 'https://rpc-mumbai.matic.today',
- DERC20: '0xfe4F5145f6e09952a5ba9e956ED0C25e3Fa4c7F1',
- DERC721: '0x757b1BD7C12B81b52650463e7753d7f5D0565C0e',
+ DERC20: '0x2d7882beDcbfDDce29Ba99965dd3cdF7fcB10A1e',
+ DERC721: '0xEC8CB8bBb069470bC358ffB0e3710c64830da383',
DERC1155: '0xA07e45A987F19E25176c877d98388878622623FA',
- MaticWETH: '0xA6FA4fB5f76172d178d61B04b0ecd319C5d1C0aa',
+ MaticWETH: '0x714550C2C1Ea08688607D86ed8EeF4f5E4F22323',
},
user: {
- privateKey: '<USER_PRIVATE_KEY>',
- address: '<USER_ADDRESS>',
- amount: '5000000000000000', // 0.005
- amount2: '7000000000000000', // 0.007
- tokenId: '1234',
+ privateKey: '0x' + '<privateKey>',
+ address: '<public key>',
+ amount: '100000000000000000', // 0.005
+ amount2: '700000000000000000', // 0.007
+ tokenId: '60399350241383852757821046101235634991156913804166740995010931519407953501076',
tokenId2: '6789',
},
}

MODIFY
examples/POS-client/utils.js
examples/POS-client/utils.js
@@ -5,14 +5,10 @@ const HDWalletProvider = require('@truffle/hdwallet-provider')
const getMaticPOSClient = () => {
return new MaticPOSClient({
- network: 'testnet', // optional, default is testnet
- version: 'mumbai', // optional, default is mumbai
+ network: 'testnet', // For mainnet change this to mainnet
+ version: 'mumbai', // For mainnet change this to v1
parentProvider: new HDWalletProvider(config.user.privateKey, config.root.RPC),
maticProvider: new HDWalletProvider(config.user.privateKey, config.child.RPC),
- posRootChainManager: config.root.POSRootChainManager,
- posERC20Predicate: config.root.posERC20Predicate, // optional, required only if working with ERC20 tokens
- posERC721Predicate: config.root.posERC721Predicate, // optional, required only if working with ERC721 tokens
- posERC1155Predicate: config.root.posERC1155Predicate, // optional, required only if working with ERC71155 tokens
parentDefaultOptions: { from: config.user.address }, // optional, can also be sent as last param while sending tx
maticDefaultOptions: { from: config.user.address }, // optional, can also be sent as last param while sending tx
})

MODIFY
examples/deposit-erc721.js
examples/deposit-erc721.js
@@ -11,4 +11,10 @@ async function execute() {
console.log(await matic.safeDepositERC721Tokens(token, tokenId, { from }))
}
-execute().then(_ => process.exit(0))
+execute()
+ .then(res => {
+ console.log(res)
+ })
+ .catch(err => {
+ console.log(err)
+ })

sample scripts updated