Skip to content

Instantly share code, notes, and snippets.

View luyzdeleon's full-sized avatar

Luis C. de Leon luyzdeleon

View GitHub Profile
@luyzdeleon
luyzdeleon / gist:ab60eca20713cada626c
Created November 15, 2014 13:46
Verifying that +luisdeleon is my openname (Bitcoin username). https://onename.io/luisdeleon
Verifying that +luisdeleon is my openname (Bitcoin username). https://onename.io/luisdeleon
@luyzdeleon
luyzdeleon / sha256.py
Created January 6, 2018 16:06
Hello World on SHA256
import hashlib
hash_object = hashlib.sha256(b'Hello World')
hex_dig = hash_object.hexdigest()
print(hex_dig)
@luyzdeleon
luyzdeleon / wallet.swift
Created September 7, 2018 14:04
Create wallet snippet
// The data parameter is not used in the Ethereum plugin
let wallet = try? PocketEth.createWallet(data: nil)
@luyzdeleon
luyzdeleon / import_wallet.swift
Created September 7, 2018 14:09
Import wallet
// The data parameter is not used in the Ethereum plugin
let privateKey = "plain_text_private_key"
let address = "0x000000000"
let importedWallet = try? PocketEth.importWallet(privateKey: privateKey, address: address, data: nil)
@luyzdeleon
luyzdeleon / transaction.swift
Created September 7, 2018 14:38
Create transaction snippet
// 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)
@luyzdeleon
luyzdeleon / query.swift
Created September 7, 2018 14:46
Create query
// Queries are structured like JSON-RPC calls, all methods are supported except sendTransaction and sendRawTransaction
let queryParams = ["rpcMethod": "eth_getTransactionCount", "rpcParams": ["0x0", "latest"]]
// The decoder is going to be used to try and decode the response in case it's a hex or any other data type that needs decoding
// You can pass in nil and get the raw response from the blockchain
let decoder = ["returnTypes": ["uint256"]]
let query = try? PocketEth.createQuery(params: queryParams, decoder: decoder)
@luyzdeleon
luyzdeleon / send_transaction.swift
Created September 7, 2018 14:50
Send transaction Pocket
Pocket.shared.sendTransaction(transaction: transaction) { (transactionResponse, error) in
if error != nil {
return
}
guard let txHash = transactionResponse?.hash else {
return
}
// Do something with the txHash
@luyzdeleon
luyzdeleon / execute_query.swift
Created September 7, 2018 14:53
Execute query Pocket
Pocket.shared.executeQuery(query: query) { (queryResponse, error) in
if error != nil {
return
}
// Do something with the queryResponse.result.value()
}
@luyzdeleon
luyzdeleon / pocket-terminal.js
Created October 21, 2019 19:40
Pocket + Terminal integration sample
const TerminalHttpProvider = require('@terminal-packages/sdk').TerminalHttpProvider;
const PocketProvider = require('pocket-js-web3-provider');
const Web3 = require('web3');
var pocketProvider = new PocketProvider("ETH", "1", "<Your Pocket Dev ID here>", {
// This is just a stub, only gets called when eth_sendRawTransaction or eth_sendTransaction are called.
transactionSigner: {
/*
Callback method called to determine wether or not the
{"genesis_time":"2020-05-22T16:04:03.57251Z","chain_id":"loadnet","consensus_params":{"block":{"max_bytes":"4000000","max_gas":"-1","time_iota_ms":"1"},"evidence":{"max_age":"1000000"},"validator":{"pub_key_types":["ed25519"]}},"app_hash":"","app_state":{"pos":{"params":{"relays_to_tokens_multiplier":"1000","unstaking_time":"1814400000000000","max_validators":"5000","stake_denom":"upokt","stake_minimum":"1000000","session_block_frequency":"25","dao_allocation":"10","proposer_allocation":"1","maximum_chains":"15","max_jailed_blocks":"1000","max_evidence_age":"120000000000","signed_blocks_window":"100","min_signed_per_window":"0.500000000000000000","downtime_jail_duration":"600000000000","slash_fraction_double_sign":"0.050000000000000000","slash_fraction_downtime":"0.010000000000000000"},"prevState_total_power":"0","prevState_validator_powers":null,"validators":[{"address":"bb6fd938b03ec5cec114ece7d1107cc24cde570d","public_key":"a1726b1cf7950cf3268ddb691cdf91e726543e4b2f28b152cce4cc77ac939094","jailed":false,"s