Skip to content

Instantly share code, notes, and snippets.

@anurag-arjun
Created January 14, 2019 12:41
Show Gist options
  • Save anurag-arjun/7d7fdedcbf0ae0854672461db053f0a9 to your computer and use it in GitHub Desktop.
Save anurag-arjun/7d7fdedcbf0ae0854672461db053f0a9 to your computer and use it in GitHub Desktop.
const Matic = require('maticjs').default
const config = require('./config')
const from = '0xdcd53258BA8A69C6a505300BE75447A772bFd3d6' // from address
const to = '0x4933ba598e6B1f33bCDc299bE76AbE2DdFbCC6A4' // to address
const token = '0x343461c74133E3fA476Dbbc614a87473270a226c' // test token address
const amount = '10000000000000000' // amount in wei (0.01 TEST)
// Create object of Matic
const matic = new Matic({
maticProvider: config.MATIC_PROVIDER,
parentProvider: config.PARENT_PROVIDER,
rootChainAddress: config.ROOTCHAIN_ADDRESS,
syncerUrl: config.SYNCER_URL,
watcherUrl: config.WATCHER_URL,
maticWethAddress: config.MATICWETH_ADDRESS,
})
matic.wallet = '0x' + config.PRIVATE_KEY // prefix with `0x`
// Send Tokens
matic.transferTokens(token, to, amount, {
from,
parent: false, // For token transfer on Main network (false for Matic Network)
onTransactionHash: () => {
// action on Transaction success
console.log("Transfer")
},
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment