Public
Edited
Oct 18, 2022
1 star
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
evmActorCid.toString()
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
skypack = (library) => import(`https://cdn.skypack.dev/${library}?min`)
Insert cell
LotusRPC = (await import('@filecoin-shipyard/lotus-client-rpc')).LotusRPC
Insert cell
BrowserProvider = (await import('@filecoin-shipyard/lotus-client-provider-browser')).BrowserProvider
Insert cell
schema = (await import('@filecoin-shipyard/lotus-client-schema')).mainnet.fullNode
Insert cell
stripAnsi = (await import('https://unpkg.com/strip-ansi@7.0.1/index.js?module')).default
Insert cell
cbor = import('https://cdn.skypack.dev/borc')
Insert cell
multiformats = import('https://cdn.skypack.dev/pin/multiformats@v9.6.5-93rn6JH3zqEZdoz77NBu/mode=imports,min/optimized/multiformats.js')
Insert cell
import {button} from '@jimpick/download-data-button-with-wasm-support'
Insert cell
buffer = require('https://bundle.run/buffer@6.0.3')
Insert cell
Insert cell
simpleCoinSol = `
// SPDX-License-Identifier: MIT
pragma solidity >=0.4.25 <= 0.8.17;

contract SimpleCoin {
mapping (address => uint) balances;

event Transfer(address indexed _from, address indexed _to, uint256 _value);

constructor() {
balances[tx.origin] = 10000;
}

function sendCoin(address receiver, uint amount) public returns(bool sufficient) {
if (balances[msg.sender] < amount) return false;
balances[msg.sender] -= amount;
balances[receiver] += amount;
emit Transfer(msg.sender, receiver, amount);
return true;
}

function getBalanceInEth(address addr) public view returns(uint){
return getBalance(addr) * 2;
}

function getBalance(address addr) public view returns(uint) {
return balances[addr];
}
}
`.trim()
Insert cell
Insert cell
Insert cell
Insert cell
client = {
const provider = new BrowserProvider(`${baseUrl}/rpc/v0`, { token })
return new LotusRPC(provider, { schema })
}
Insert cell
async function *heightStream () {
let last
while (true) {
try {
const newHeight = (await client.chainHead()).Height
if (newHeight !== last) {
yield newHeight
last = newHeight
}
} catch (e) {
yield 0
}
await Promises.delay(4000)
}
}
Insert cell
mutable ready = false
Insert cell
async function *heightReadyTapStream () {
let lastReady = false
for await (const height of heightStream()) {
const newReady = height > 7
if (newReady !== lastReady) {
mutable ready = newReady
lastReady = newReady
}
yield height
}
}
Insert cell
currentHeight = heightReadyTapStream()
Insert cell
walletDefaultAddress = ready && client.walletDefaultAddress()
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more