UNPKG

ethstorage-sdk-ts

Version:

eip-4844 blobs upload sdk from ethstorage-sdk

41 lines (40 loc) 1.49 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const ethers_1 = require("ethers"); const dotenv_1 = __importDefault(require("dotenv")); dotenv_1.default.config(); const _1 = require("."); const getWallet = () => { const pk = process.env.privateKey; if (pk) { return new ethers_1.Wallet(pk); } else { const wallet = ethers_1.Wallet.createRandom(); console.log(`privateKey: ${wallet.privateKey}`); console.log(`address ${wallet.address}`); return wallet; } }; const getRpc = () => { return new ethers_1.ethers.JsonRpcProvider(process.env.rpc); }; const main = async () => { const wallet = getWallet(); const rpc = getRpc(); const balance = await rpc.getBalance(wallet.address); const storage = new _1.EthStorageNode(process.env.rpc, wallet.privateKey, "0xbe3EEe31e274aabf33F455D5b29Cc96329FC39eb"); console.log(`wallet address : ${wallet.address}`); console.log(`balance : ${(0, ethers_1.formatEther)(balance)} `); const fileOrPath = "./package.json"; await storage.upload(fileOrPath); // const flatAddress = await storage.deploySepolia(); // console.log(flatAddress); await storage.uploadData("/world", "Hello World"); await storage.remove("/world"); await storage.remove("/package.json"); }; main();