You can do following to allow passing blob into contract without a lot of overhead:
export function setContractToDeploy(): void {
env.input(0);
util.read_register(0);
// ...
}
select | |
format_timestamp('%m/%d/%Y %H:%M:%S', timestamp_millis(div(block_timestamp, 1000000))) as `Date`, | |
parse_bignumeric(json_value(args, '$.deposit')) / POW(cast(10 as bignumeric), 24) as `Sent Quantity`, | |
'NEAR' as `Sent Currency` | |
, receipt_predecessor_account_id | |
, receipt_receiver_account_id | |
from `bigquery-public-data.crypto_near_mainnet_us.receipt_actions` | |
where receipt_predecessor_account_id in | |
( | |
'vlad.near', |
// Tokenize the JSON string by splitting on `{`, `}`, `[`, and `]`, unless the character is inside a string | |
char* token = strtok(jsonCopy, "{}[],"); | |
bool inString = false; | |
int depth = 0; | |
while (token != NULL) { | |
if (!inString && depth == 0 && strcmp(token, path) == 0) { | |
// The requested path was found, so return the next token as the value | |
token = strtok(NULL, "{}[],"); | |
slice_t value = { | |
.len = strlen(token), |
const std = @import("std"); | |
// NOTE: In smart contract context don't really have to free memory before execution ends | |
var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator); | |
var allocator = arena.allocator(); | |
// Import host functions provided by NEAR runtime. | |
// See https://github.com/near/near-sdk-rs/blob/78c16447486285fd952765ef3e727e16d6c8c867/near-sdk/src/environment/env.rs#L117 | |
extern fn input(register_id: u64) void; | |
extern fn read_register(register_id: u64, ptr: u64) void; |
select | |
to_timestamp(receipt_included_in_block_timestamp / 1000000000) as timestamp, | |
(args->>'deposit')::numeric / (10 ^ 24) as deposit, | |
receipt_predecessor_account_id | |
from action_receipt_actions | |
where receipt_receiver_account_id = 'root.near' | |
and receipt_predecessor_account_id != 'system' |
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<title>js-libp2p parcel.js browser example</title> | |
</head> | |
<body> |
You can do following to allow passing blob into contract without a lot of overhead:
export function setContractToDeploy(): void {
env.input(0);
util.read_register(0);
// ...
}
async function deploy(options) { | |
const configPath = process.cwd() + '/src/config'; | |
const config = require(configPath)(process.env.NODE_ENV || 'development'); | |
const near = await nearlib.connect({...config, deps: { keyStore: new UnencryptedFileSystemKeyStore('./neardev') } }); | |
const contractData = [...fs.readFileSync(options.wasmFile)]; | |
const account = await near.account(options.accountId); | |
await account.signAndSendTransaction(options.accountId, [ | |
deployContract(contractData), | |
// TODO: Use whatever actual params need to be for functionCall or include any other actions as well |
[I] ➜ yarn start | |
yarn run v1.21.1 | |
warning package.json: No license field | |
$ npm run build && near deploy --wasmFile ./contract/res/status_message.wasm | |
npm WARN lifecycle The node binary used for scripts is /var/folders/3c/zjk2krns25s75x_z2_wdvgg80000gn/T/yarn--1580160108615-0.8711654915114355/node but npm is using /Users/vg/n/bin/node itself. Use the `--scripts-prepend-node-path` option to include the path for the node binary npm was executed with. | |
> [email protected] build /Users/vg/Documents/create-near-app/blank-rust-proj-vg | |
> cd contract && ./build.sh | |
Updating crates.io index |
sqlite3 = require('sqlite3') | |
db = new sqlite3.Database('db/testnet-database.sqlite') | |
db.all(`select name from sqlite_master where type='table'`, console.log) | |
db.all(`select * from transactions where actions like '%deploy%' limit 10`, console.log) | |
db.all(`select count(*) from transactions where actions like '%deploy%' limit 10`, console.log) |
const nearlib = require('nearlib'); | |
const { signTransaction, transfer } = nearlib.transactions; | |
const { base_decode } = nearlib.utils.serialize; | |
const sleep = (ms) => new Promise((resolved) => setTimeout(resolved, ms)); | |
(async () => { | |
const [,, accountId, txCount] = process.argv; | |
const near = await nearlib.connect({...require('near-shell/get-config')(), deps: { keyStore: new nearlib.keyStores.UnencryptedFileSystemKeyStore('./neardev') } }); |