Skip to content

Instantly share code, notes, and snippets.

View xJonathanLEI's full-sized avatar
🦀
Rewriting stuff in Rust™

Jonathan LEI xJonathanLEI

🦀
Rewriting stuff in Rust™
View GitHub Profile
await eos.pushTransaction(myTx.transaction);
await eos.pushTransaction(myTx.transaction);
const txHeader = await getHeader();
const coldEos = Eos({
httpEndpoint: null,
chainId: "your_chain_id",
keyProvider: "your_private_key",
transactionHeaders: txHeader
});
coldEos.fc.abiCache.abi("your_account_name", abi);
async function getHeader() {
const expireInSeconds = 60 * 60 // 1 hour
const info = await eos.getInfo({})
const chainDate = new Date(info.head_block_time + 'Z')
let expiration = new Date(chainDate.getTime() + expireInSeconds * 1000)
expiration = expiration.toISOString().split('.')[0]
const block = await eos.getBlock(info.last_irreversible_block_num)
eos.fc.abiCache.abi("your_account_name", abi);
eos.setcode("your_account_name", 0, 0, wasm);
const fs = require("fs");
const wasm = fs.readFileSync("/path/to/wasm/file");
const abi = JSON.parse(fs.readFileSync("/path/to/abi/file"));
contractSubcommand->set_callback([&] {
shouldSend = false;
set_code_callback();
set_abi_callback();
std::cerr << localized("Publishing contract...") << std::endl;
send_actions(std::move(actions), 10000, packed_transaction::zlib);
});
{
"structs": [
{
"name": "transfer",
"base": "",
"fields": [
{
"name": "from",
"type": "account_name"
},