五月天青色头像情侣网名,国产亚洲av片在线观看18女人,黑人巨茎大战俄罗斯美女,扒下她的小内裤打屁股

歡迎光臨散文網(wǎng) 會員登陸 & 注冊

九星創(chuàng)客系統(tǒng)開發(fā)(開發(fā)詳細(xì))丨創(chuàng)客互助公排系統(tǒng)開發(fā)(開發(fā)邏輯)

2023-02-27 10:21 作者:bili_16249894763  | 我要投稿

智能合約是運(yùn)行在區(qū)塊鏈公鏈上的一種代碼,該代碼由Solidity編寫,并通過區(qū)塊鏈的智能合約虛擬機(jī)來執(zhí)行,以達(dá)到對區(qū)塊鏈編程的目標(biāo)??梢詫^(qū)塊鏈公聯(lián)理解為操作系統(tǒng),Solidity是編寫該操作系統(tǒng)應(yīng)用程序的編程語言,智能合約虛擬機(jī)則是編程語言編譯之后的代碼運(yùn)行環(huán)境。


  var fs=require('fs');


  const fetch=require('node-fetch')


  var Web3=require('web3');


  const ethers=require('ethers');


  const infuraKey=fs.readFileSync("../.infuraKey").toString().trim();


  var ethRpcUrl=`https://rinkeby.infura.io/v3/`+infuraKey


  var web3=new Web3(ethRpcUrl);


  abi=[開發(fā)源碼及部署I35詳細(xì)7O98開發(fā)O7I8


  {


  "inputs":[],


  "name":"getValue",


  "outputs":[


  {


  "internalType":"uint256",


  "name":"",


  "type":"uint256"


  }


  ],


  "stateMutability":"view",


  "type":"function"


  },


  {


  "inputs":[功能及案例:MrsFu123


  {


  "internalType":"uint256",


  "name":"_value",


  "type":"uint256"


  }


  ],


  "name":"setValue",


  "outputs":[],


  "stateMutability":"nonpayable",


  "type":"function"


  }


  ]


  contractAddress="合約地址"


  pk="錢包私鑰"


  userAccount="私鑰對應(yīng)的賬戶地址"


  main()


  .then(()=>process.exit(0))


  .catch(error=>{


  console.error(error);


  process.exit(1);


  });


  async function main(){


  await setValue();


  await getValue();


  }


  async function getNonce(account){


  let nonce=await web3.eth.getTransactionCount(account);


  console.log('nonce=',nonce)


  return nonce;


  }


  async function getValue(){


  //對方法進(jìn)行sha3編碼,然后取前四個(gè)字節(jié)


  //var methodSign=await web3.utils.keccak256("getValue()").substr(0,10);


  var methodSign=await web3.utils.keccak256("getValue()").substr(0,10);


  //console.log(methodSign)


  data=methodSign;


  //如果有入?yún)?,對入?yún)⑦M(jìn)行編碼


  //encodeParams=web3.eth.abi.encodeParameters(['uint256'],[456]);


  //拼接方法名和入?yún)⒆鳛閖sonrpc的params中的data字段的數(shù)據(jù)


  //data+=encodeParams.substr(2,encodeParams.length)


  console.log(data)


  //構(gòu)造post請求的body參數(shù)


  var input={"jsonrpc":"2.0","id":3,"method":"eth_call","params":[{"to":contractAddress,"data":data},"latest"]}


  //http可以一次多個(gè)請求


  var inputs=[input,input]


  //發(fā)送post請求


  const resp=await fetch(ethRpcUrl,{


  method:"POST",


  body:JSON.stringify(inputs),


  headers:{


  "Content-Type":"application/json"


  }


  });


  var rpcResult=await resp.json();


  console.log(rpcResult[0].result)


  //用ethers包中的方法解析返回結(jié)果


  var ethersResult=await ethers.utils.defaultAbiCoder.decode(['uint256'],rpcResult[0].result)


  //用web3包中的方法解析防護(hù)結(jié)果


  var decodeResult=await web3.eth.abi.decodeParameters(['uint256'],rpcResult[0].result);


  console.log("vaule is"+ethersResult)


  console.log("value is"+decodeResult[0])


  }


  async function setValue(){


  //這里借用web3的方法對要發(fā)送的內(nèi)容進(jìn)行簽名


  var contract=new web3.eth.Contract(abi,contractAddress);


  value=456;


  var encodeABI=contract.methods.setValue(value).encodeABI();


  var signResult=await web3.eth.accounts.signTransaction({


  gas:3000000,


  to:contractAddress,


  data:encodeABI,


  nonce:await getNonce(userAccount)


  },pk);


  console.log(signResult);


  rawTransaction=signResult.rawTransaction


  //構(gòu)造post請求的body參數(shù)


  var input={"jsonrpc":"2.0","id":3,"method":"eth_sendRawTransaction","params":[rawTransaction]}


  console.log(input)


  var inputs=[input]


  //發(fā)送post請求


  const resp=await fetch(ethRpcUrl,{


  method:"POST",


  body:JSON.stringify(inputs),


  headers:{


  "Content-Type":"application/json"


  }


  });


  var rpcResult=await resp.json();


  console.log(rpcResult)


  }


九星創(chuàng)客系統(tǒng)開發(fā)(開發(fā)詳細(xì))丨創(chuàng)客互助公排系統(tǒng)開發(fā)(開發(fā)邏輯)的評論 (共 條)

分享到微博請遵守國家法律
睢宁县| 潼关县| 泾源县| 镇宁| 桑日县| 富裕县| 会宁县| 汕尾市| 雷波县| 郴州市| 遵化市| 永宁县| 西峡县| 格尔木市| 浦北县| 封开县| 福泉市| 景泰县| 太保市| 浦城县| 扶沟县| 大理市| 娄底市| 固镇县| 麟游县| 柳州市| 邵武市| 沛县| 余姚市| 崇左市| 海口市| 宁安市| 松溪县| 新平| 柏乡县| 松阳县| 阳山县| 舞阳县| 郓城县| 任丘市| 桂阳县|