Polygon

// MAIN METHODS

//secret_key - private key or (!) mnemonic frase
//you could create private keys, for getting it, please call bellow method
//$D.crypto.network('polygon').createKeys().private


var network = $D.crypto.network('polygon')
//var secret_key = network.createKeys().private
var wallet = network.wallet(secret_key) // or mnemonic frase
wallet.address // return 0xDEC0DE7...20
wallet.getBalance("") // return 3.13382020888302508 MATIC
//count tokens by contract
wallet.getBalance("0x2791bca1f2de4661ed88a30c99a7a9449aa84174") // return 7.500000 USDC
wallet.getBalance("USDC") // return 7.500000 USDC

//
//send main coin (ETH,MATIC)
wallet.send("0x25Cbd...2D2", "0.1") 
//code above returns hash address for the transaction

//send tokens by standard EIP-20 and ERC20
wallet.send("0x25Cbd...2D2", "0.1", "0x2791bca1f2de4661ed88a30c99a7a9449aa84174")
//code above send 0.1 USDC tokens to 0x25Cbd...2D2 address
wallet.send("0x25Cbd...2D2", "0.1", "USDC")
//code above send 0.1 USDC tokens to 0x25Cbd...2D2 address

wallet.getTransaction("API_TOKEN_FOR_GETTING_DATA_ON_SCANNER") 
//getTransaction return tranactions and saving it on CryptoTransaction structures



// UTILS
$D.crypto.utils.convert("1 MATIC", "USD") //method return 1.4 (1 Matic ~ 1.4 USD)
$D.crypto.utils.convert("1 USDC", "USD") //method return 0.99 (1 USDC ~ 0.99 USD on the exchanges)

$D.crypto.utils.normalize("30000000000", "12")
//method return 30 (usefull for convert raw data) 

Last updated