Skip to content

Instantly share code, notes, and snippets.

use serde::{Deserialize, Serialize};
use serde_json::to_string;
#[derive(Debug, Deserialize, Serialize, Clone)]
pub struct UnsafeQuery {
pub key: String,
pub value: Vec<u8>,
}
impl UnsafeQuery {
// taken and modified from here https://gist.github.com/gluk64/fdea559472d957f1138ed93bcbc6f78a#file-reason-js
// This is universal, works with Infura -- set provider accordingly
const ethers = require('ethers')
const { TEAMS_ENDPOINT } = require("./credentials.js")
const provider = new ethers.providers.JsonRpcProvider();
// const provider = new ethers.getDefaultProvider("rinkeby")
library Storage {
struct Structing {
uint256 this;
mapping (uint256 => bool) that;
} // this does not require linking and is therefore embedding in contract demo?
function bePublic () public {
} // with this function library should not embed, yet it does not seem to work
}
contract demo {
const ethers = require('ethers');
const { TEAMS_ENDPOINT } = require("./credentials.js")
const provider = new ethers.providers.JsonRpcProvider(TEAMS_ENDPOINT);
const block = async () => {
const blockNumber = await provider.getBlock("latest")
console.log(blockNumber)
}
const ethers = require('ethers');
const {TEAMS_API, BOT_PRIVATE_KEY} = require("./credentials")
const provider = new ethers.providers.JsonRpcProvider(TEAMS_API);
const wallet = new ethers.Wallet(BOT_PRIVATE_KEY, provider);
const transaction = async () => {
let value = ethers.utils.parseEther('0.000000001');
// taken and modified from here https://gist.github.com/gluk64/fdea559472d957f1138ed93bcbc6f78a#file-reason-js
// This is universal, works with Infura -- set provider accordingly
const ethers = require('ethers')
const { TEAMS_ENDPOINT } = require("./credentials.js")
const provider = new ethers.providers.JsonRpcProvider(TEAMS_ENDPOINT);
const ethers = require('ethers');
const { MNEUMONIC } = require("./credentials.js")
// increment the last digit by 1 to get a new wallet
let path = "m/44'/60'/0'/0/0";
const wallets = ethers.Wallet.fromMnemonic(MNEUMONIC, path)
console.log(wallets)
const ethers = require('ethers');
const {LOCAL_API, BOT_PRIVATE_KEY} = require("./credentials")
const provider = new ethers.providers.JsonRpcProvider(LOCAL_API);
const wallet = new ethers.Wallet(BOT_PRIVATE_KEY, provider);
const transaction = async () => {
let value = ethers.utils.parseEther('0.000000001');