Created
September 7, 2018 14:38
-
-
Save luyzdeleon/bdba054f11d0c8fdb3aefe5ee773f581 to your computer and use it in GitHub Desktop.
Create transaction snippet
This file contains hidden or 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
// Ethereum's transaction object | |
var params = [AnyHashable : Any]() | |
params["to"] = "0x0000000000" | |
params["data"] = nil | |
params["nonce"] = BigUInt.init(0) | |
// In wei | |
params["gasPrice"] = BigUInt.init(0) | |
params["gasLimit"] = BigUInt.init(0) | |
params["value"] = BigUint.init(0) | |
// For custom data just use a Data object | |
params["data"] = Data.init() | |
// For smart contract calls use a Dictionary with the following structure | |
params["data"] = [AnyHashable: Any]() | |
params["data"]["abi"] = "" // Raw abi JSON for the specific function you're calling | |
params["data"]["params"] = [Object]() // Parameters for the function in the same order specified for the smart contract abi | |
let wallet = try? PocketEth.createWallet(data: nil) | |
// The "from" param for the transaction is automatically extracted from the Wallet object | |
let transaction = try? PocketEth.createTransaction(wallet: wallet!, params: params) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment