摘要:交易为了能够在区块链上发送交易和触发操作,你必须具有实例。签名提供程序必须包含与执行者和操作权限相对应的私钥。示例示例创建新帐户多个操作上一篇浏览器下一篇读取区块链
交易
为了能够在区块链上发送交易和触发操作,你必须具有Api实例。
签名提供程序必须包含与执行者和操作权限相对应的私钥。
const { Api, JsonRpc } = require("eosjs"); const JsSignatureProvider = require("eosjs/dist/eosjs-jssig"); // development only const fetch = require("node-fetch"); // node only; not needed in browsers const { TextDecoder, TextEncoder } = require("text-encoding"); // node, IE11 and IE Edge Browsers const privateKeys = [privateKey1]; const signatureProvider = new JsSignatureProvider.default(privateKeys); const rpc = new JsonRpc("http://127.0.0.1:8888", { fetch }); const api = new Api({ rpc, signatureProvider, textDecoder: new TextDecoder(), textEncoder: new TextEncoder() });示例 Buy ram
const result = await api.transact({ actions: [{ account: "eosio", name: "buyrambytes", authorization: [{ actor: "useraaaaaaaa", permission: "active", }], data: { payer: "useraaaaaaaa", receiver: "useraaaaaaaa", bytes: 8192, }, }] }, { blocksBehind: 3, expireSeconds: 30, });Stake
const result = await api.transact({ actions: [{ account: "eosio", name: "delegatebw", authorization: [{ actor: "useraaaaaaaa", permission: "active", }], data: { from: "useraaaaaaaa", receiver: "useraaaaaaaa", stake_net_quantity: "1.0000 SYS", stake_cpu_quantity: "1.0000 SYS", transfer: false, } }] }, { blocksBehind: 3, expireSeconds: 30, });示例:Unstake
const result = await api.transact({ actions: [{ account: "eosio", name: "undelegatebw", authorization: [{ actor: "useraaaaaaaa", permission: "active", }], data: { from: "useraaaaaaaa", receiver: "useraaaaaaaa", unstake_net_quantity: "1.0000 SYS", unstake_cpu_quantity: "1.0000 SYS", transfer: false, } }] }, { blocksBehind: 3, expireSeconds: 30, });创建新帐户(多个操作)
const result = await api.transact({ actions: [{ account: "eosio", name: "newaccount", authorization: [{ actor: "useraaaaaaaa", permission: "active", }], data: { creator: "useraaaaaaaa", name: "mynewaccount", owner: { threshold: 1, keys: [{ key: "PUB_R1_6FPFZqw5ahYrR9jD96yDbbDNTdKtNqRbze6oTDLntrsANgQKZu", weight: 1 }], accounts: [], waits: [] }, active: { threshold: 1, keys: [{ key: "PUB_R1_6FPFZqw5ahYrR9jD96yDbbDNTdKtNqRbze6oTDLntrsANgQKZu", weight: 1 }], accounts: [], waits: [] }, }, }, { account: "eosio", name: "buyrambytes", authorization: [{ actor: "useraaaaaaaa", permission: "active", }], data: { payer: "useraaaaaaaa", receiver: "mynewaccount", bytes: 8192, }, }, { account: "eosio", name: "delegatebw", authorization: [{ actor: "useraaaaaaaa", permission: "active", }], data: { from: "useraaaaaaaa", receiver: "mynewaccount", stake_net_quantity: "1.0000 SYS", stake_cpu_quantity: "1.0000 SYS", transfer: false, } }] }, { blocksBehind: 3, expireSeconds: 30, });上一篇:浏览器 下一篇:读取区块链
文章版权归作者所有,未经允许请勿转载,若此文章存在违规行为,您可以联系管理员删除。
转载请注明本文地址:https://www.ucloud.cn/yun/100518.html
摘要:参数名称类型默认值返回如果,则节点响应,如果则。上一篇读取区块链下一篇接口 API 类 Api 变量 abiAbi transactionAbi 变量 abiAbi abiAbi:any = require(../src/abi.abi.json) 定义于eosjs-api.ts:12 transactionAbi transactionAbi:any = require(...
摘要:接口接口实现类属性定义于检索。类型声明参数名称类型返回属性定义于与保存的私钥关联的公钥。定义于已部署的帐户。定义于二进制形式的。类型声明返回定义于签名交易。 API接口 接口 AbiProvider AuthorityProvider AuthorityProviderArgs BinaryAbi CachedAbi SignatureProvider SignatureProvid...
摘要:介绍用于使用与基于的区块链集成的。在浏览器中使用并不安全,只能用于开发目的,在网页上下文之外使用安全保管库,以确保在生产中签名交易时的安全性。错误处理使用处理错误。上一篇文档目录下一篇浏览器 介绍 用于使用EOSIO RPC API与基于EOSIO的区块链集成的Javascript API。 安装 NodeJS依赖 npm install eosjs@beta or yarn add ...
摘要:浏览器用法或。为所有交易重用对象,它缓存以减少网络使用,只调用一次。和支持如果你需要支持或,你还需要安装文本编码的,因为签名依赖于和不提供的。将和传递给构造函数,请参阅中的文档,以确定将其包含在项目中的最佳方法。上一篇介绍下一篇交易 浏览器 用法 npm run build-web或yarn build-web。 为所有交易重用api对象,它缓存ABI以减少网络使用,只调用一次new ...
摘要:类实现接口构造函数定义于参数名称类型描述用于签名的私钥返回属性定义于公钥。方法定义于与保存的私钥关联的公钥。返回定义于签名交易。 JS-Sig 类 JsSignatureProvider JsSignatureProvider 实现接口 SignatureProvider 构造函数 new JsSignatureProvider(privateKeys: string[]): JsSi...
阅读 1856·2021-11-15 11:39
阅读 1037·2020-12-03 17:06
阅读 715·2019-12-27 11:42
阅读 3251·2019-08-30 13:59
阅读 1438·2019-08-26 13:22
阅读 3269·2019-08-26 12:15
阅读 2455·2019-08-26 10:22
阅读 1542·2019-08-23 18:40