抛砖引玉,用老版eosjs案例,希望引出20+版本案例

管理员组 缘雨 1月前 55

直接上代码:(这是我用来部署合约的一个js)

const Eos = require('eosjs');
var http = require('http');
var url = require('url');
var express = require('express');
const ecc = require('eosjs-ecc');
fs = require('fs');
var app = express();

const home="你的账户名";

const httpEndpoint = 'http://39.108.231.157:30065//麒麟测试网的节点';
const chainId = '5fff1dae8dc8e2fc4d5b23b2c7665c97f9e9d8edf2b6485a86ba311c25639191';//麒麟创世节点
const key = 'xxx';//你的私钥,active的,

const config = {
// private keys used to request net
keyProvider: [key], // 配置私钥字符串

httpEndpoint: httpEndpoint, // mainNet bp endpoint
chainId: chainId, // 通过cleos get info可以获取chainId
expireInSeconds: 1000,
broadcast: true,
debug: false,
sign: true,
authorization: null // 该参数用于在多签名情况下,识别签名帐号与权限,格式如:account@permission
// transactionHeaders: (expireInSeconds, callback) => {
// callback(null/error/, headers) //手动设置交易记录头,该方法中的callback回调函数每次交易都会被调用
// },
};

const eos = Eos(config);

module.exports = {
home,
eos,
key
};

app.get('/',function(req,res) {
wasm = fs.readFileSync(token.wasm) ;//导入token.wasm文件,注意这里是相对路经,你也可以用绝对路径
abi = fs.readFileSync(token.abi);//同上

eos.setcode({account:home,vmtype: 0, vmversion:0,code: wasm},
{authorization: [${home}@active]}) 
eos.setabi({account:home, abi:JSON.parse(abi)},{authorization: [${home}@active]});
app.listen(7777);
还没有人收藏过本帖~
最新回复 (1)
  • 管理员组 Surou 1月前
    0 引用 2
    贴点参考
    https://www.bcskill.com/index.php/archives/700.html
    https://eosio.github.io/eosjs/guides/2.-Transaction-Examples.html
返回