web3

web3.eth.sendSignedTransaction() always return “Returned error: nonce too low”

纵然是瞬间 提交于 2020-05-28 03:28:12
问题 I used web3@1.00 in node.js to interact with private blockchain. And I write the code according to the official documents of web3@1.00. var Web3 = require('web3'); var Tx = require('ethereumjs-tx'); var web3 = new Web3('http://localhost:8101'); //get the privatekey var decryptPK = web3.eth.accounts.decrypt({"address":"68c5cb5aa9f568ae2a6ec530e982f4f1144f2d10", "crypto":{"cipher":"aes-128-ctr", "ciphertext":"96b6a86bd5ff16a5669975974eabba844bc414bc52d9cc36843b4f41e89d46b9", "cipherparams":{"iv

Objects are not valid as a React child. If you meant to render a collection of children, use an array instead - Error Solidity - React

£可爱£侵袭症+ 提交于 2020-04-30 09:18:07
问题 I am developing a document verification system with ReactJS and solidity - smart contract. I want to display the result of my smart contract's get().call() method on the frontend, with a popup or even with a simple text. The problem I am facing now is that when I am trying to display the response of the method, it throws to me that error: Objects are not valid as a React child. If you meant to render a collection of children, use an array instead Here is the code of my solidity contract:

web3.eth.accounts

情到浓时终转凉″ 提交于 2020-03-02 08:49:51
如果你希望马上开始学习以太坊DApp开发,可以访问汇智网提供的出色的在线互动教程: 以太坊DApp实战开发入门 去中心化电商DApp实战开发 只读属性,返回当前节点持有的帐户列表。 同步调用: web3.eth.accounts 异步调用: web3.eth.getAccounts(callback(error, result){ ... }) 返回值: Array - 节点持有的帐户列表。 示例: var accounts = web3.eth.accounts; console.log(accounts); 以太坊开发入门教程 来源: oschina 链接: https://my.oschina.net/u/3794778/blog/1800236

Send ERC20 token with web3

时光怂恿深爱的人放手 提交于 2020-01-08 16:26:42
问题 I'm currently using 0.2x.x version of Web3 Javascript API. I deployed my custom ERC20 token by creating smart contract in solidity (on REMIX IDE). I installed the MetaMask and had a test on https://wallet.ethereum.org/ to send some custom ERC token to another my account. It worked well. I want to add the 'send custom ERC20 Token' function in my javascript code using Web3. Here is my code below. var http = require('http'); var Web3 = require('web3'); var Tx = require('ethereumjs-tx'); var abi

Send ERC20 token with web3

大憨熊 提交于 2020-01-08 16:25:10
问题 I'm currently using 0.2x.x version of Web3 Javascript API. I deployed my custom ERC20 token by creating smart contract in solidity (on REMIX IDE). I installed the MetaMask and had a test on https://wallet.ethereum.org/ to send some custom ERC token to another my account. It worked well. I want to add the 'send custom ERC20 Token' function in my javascript code using Web3. Here is my code below. var http = require('http'); var Web3 = require('web3'); var Tx = require('ethereumjs-tx'); var abi

Private Network : web3.eth.getAccounts() always send empty array

白昼怎懂夜的黑 提交于 2020-01-02 09:58:16
问题 I am running a private Ethereum network. I do use https://aws.amazon.com/blockchain/templates/ The entire setup has been done. Things look setup properly on AWS. Now, I am trying to create the account and retrieve all those accounts. For that, I am using methods as below. Web3Service.js var Web3 = require('web3'); var web3 = new Web3(new Web3.providers.HttpProvider(process.env.NETWORK_URL)); exports.getAccounts = function () { return web3.eth.getAccounts(); }; exports.createAccount = function

web3.eth.getAccounts() returns empty

狂风中的少年 提交于 2019-12-25 01:48:41
问题 I try implement a simple bank account example (get balance, deposit, withdraw). pragma solidity 0.5.1; contract Bank { int bal; constructor() public { bal = 1; } //get balance function function getBalance () view public returns(int) { return bal; } //withdraw money function withdraw (int amt) public { bal = bal - amt; } //deposit money function deposit (int amt) public { bal = bal + amt; } } I can get the balance of a simple account but I cannot use the deposit/withdraw functions as web3.eth

Is it secure to run public ethereum node?

萝らか妹 提交于 2019-12-21 21:22:20
问题 I'm creating my first Ethereum contract with truffle. I want the web application to be usable without MetaMask so I was wondering if it is a good idea to run my own private node and to connect from the frontend like this: this.web3 = new Web3(new Web3.providers.HttpProvider('http://my-public-ip:8545')); Are there any security risks with this approach ? 回答1: I'm answering my own question because it seems that a lot of people are doinig the same mistake that I did and lose their ether ! I did

How to get a value from a “Promise” object

二次信任 提交于 2019-12-20 03:56:21
问题 I started learning ethereum and web3js and noticed some functions on Web3js are asynchronous. What i want to achieve is get the account balance of a wallet and use the data for something else. My code below function getAccountBalance2(address){ var wei, balance //address = document.getElementById("addy").value return new Promise(function(resolve, reject){ web3.eth.getBalance(address, function(error, wei){ if(error){ console.log("Error with address"); }else{ var balance = web3.fromWei(wei,

How to set state of a react component with a specific item from a returned json object?

血红的双手。 提交于 2019-12-18 09:46:26
问题 This is a follow up question to the previous thread How to return json data to a react state? My react component makes an axios.post to an express server. The server uses web3 to sign a transaction onto Ethereum . Ethereum returns the following json object. Of note is that it takes some time (seconds to minutes depending on the miners) for the json to be returned: { blockHash: '0xcd08039bac40e2865886e8f707ce9b901978c339d3abb81516787b0357f53fbd', blockNumber: 4611028, ...other data...