Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [web3js]

Javascript API and library for Ethereum To develop applications on Ethereum, you can use the web3 object provided by the web3.js library. Under the hood it communicates to a local node through RPC calls. web3.js works with any Ethereum node, which exposes an RPC layer. https://github.com/ethereum/wiki/wiki/JavaScript-API

1
vote
1answer
139 views

Web3.js: how to efficiently load and display bunch of items from the Blockchain?

I am developing a DApp and I am struggling with the efficient loading from the blockchain and displaying in the frontend. I am loading all the items at once. When the list of the items grows very ...
0
votes
1answer
149 views

How can I show on web3j a list of all the instructors added on my blockchain?

I need to show on an html a list of all the instructors that are set up on the list pragma solidity ^0.4.18; contract Owned { address owner; function Owned() public { owner = msg.sender; } ...
0
votes
1answer
138 views

Web wallet best practices

I'm putting together an ether/erc20 token wallet in a chrome extension but would like to follow best practices with regards to private key security. I'm using localstorage to handle login and its ...
3
votes
1answer
90 views

List holders and tokens for an ERC-721 contract

Given a contract, I want to map the holders to their token ids. For example, the contract 0xFBeef911Dc5821886e1dda71586d90eD28174B7d is an ERC-721 contract for KnownOriginDigitalAsset. Etherscan ...
4
votes
1answer
163 views

How to exchange ETH to DAI with web3 and node.js

I looking for solution how to convert eth to dai with web3 api. something like https://kyber.network/swap/eth_knc (I can send eth to specyfic contract adress and I receive back DAI to the same ...
0
votes
3answers
22 views

Integration of smart contact with frontend using web3js [on hold]

I had been long searching methods fro integration my smart contract with my frontend. Then I came across web3.js but couldn't find any specific method is to how this system is working.
0
votes
2answers
143 views

Web3js 1.0.x: contract.at not a function

I am trying to follow this flow to access a contract that has been mined previously: var MyContract = new web3.eth.Contract(abiJSON); // instantiate by address var contractInstance = MyContract.at(...
1
vote
1answer
13 views

How to improve web3 when importing and stop doing the same task over and over again?

When using web3js, you will automatically have to make file to create an instance of that contract which you will use in your main project to interact with. For example, smartContract.js import ...
6
votes
2answers
6k views

Metamask error: “Transaction Error. Exception thrown in contract code.” (plain HTML + JS front)

I successfully implemented a smart contract using remix in the Rinkeby testnet, and can interact with it from remix. Now I'm building a simple frontend for it but although I have been able to obtain ...
0
votes
1answer
159 views

Sweep funds from all accounts into one account

How can i sweep funds of all ethereum accounts into one eth wallet using web3 in ubuntu server? Is there any example for the same? i found an example but that is not working for me.
0
votes
1answer
167 views

Ethereum Event log

is it possible to watch the events of any ethereum transaction? like for erc20 token. when we make any transaction of erc20 on the blockchain event get trigger. is same is possible for ETH transaction....
0
votes
1answer
17 views

How to use soliditySha3 in web3py

I have tested soliditySha3 function with web3js. var msg = web3Infura.utils.soliditySha3("transferPreSigned", mainContractAddress, recepientAddress, tokenAmountWei, transferFee, randomNounce); I ...
0
votes
1answer
152 views

Why myContract.events.MyEvent([options][, callback]) does not return “data” and “logs”?

We have an event as follows : event LogNewObject(address sender, bytes32 indexed id, bytes32 sub_states_types, bytes32 sub_states_values, address owner); This event is called in following function : ...
1
vote
1answer
147 views

Exceeds block gas limit error to call view functions

With solidity view function, you can specific the amount of gas to use. My understand is since it is not a state changing transaction, all the gas cost is not charged for, and the client should be ...
1
vote
1answer
144 views

creating multi signature address in solidity

How can I create an array of multi-signature address (2-of-2 P2SH multisig, keeping one account on all the multi-signature account constant) in web3js or solidity so that my custom token can be ...
0
votes
1answer
8 views

How do you add miner address so that it can mint tokens?

I have ERC721 that I'm making. function mint(address to, uint256 tokenId) public onlyMinter returns (bool) { _mint(to, tokenId); return true; } How can I add an address so that it is able ...
0
votes
1answer
146 views

Why does the transaction stay in queue from more than 240 second

I am running quorum nodes via the Quorum-maker script, and when trying to call functions from my already deployed smart contract, I get this error : Transaction ...
0
votes
1answer
153 views

Trouble running node to test Web3

I'm trying to test basic web3 with node. I have testrpc running and I have the following in a javascript file: var Web3 = require('web3'); var web3 = new Web3(new Web3.providers.HttpProvider("http://...
0
votes
1answer
172 views

Subscribe to balance using web3

There is some way that I can subscribe to the balance to a address using web3js of Eth
1
vote
1answer
182 views

how get to nonce that need to send in ethereum transaction?

I have written down node js code to send eth using web3. I am getting nonce value using getTransactionCount which is working fine but as all know it can not count pending transaction so if i send ...
1
vote
1answer
141 views

Finding total eth amount sent to contract from address

I am implementing a simple tokensale platform using web3.js. It should display to the user 'You have already sent us 2.3 ETH and recieved 1003 tokens'. It is easy to find out how many tokens the ...
0
votes
0answers
22 views

i am trying to send a signed transaction for my solidity code but i am encounting some error can anyone suggest me the fix?

pragma solidity^0.5.0; import "./TokenSale.sol"; contract Dice{ TokenSale public tokenSale; address tokensaleaddress; struct player_details{ address pAddress; string ...
0
votes
1answer
164 views

How to get only past 2 days events using getPastEvents everytime?

How can the following query be modified to only fetch the past two days worth of events: const events= await MyContract.getPastEvents("eventName", { fromBlock: 0, toBlock: "latest" });
0
votes
1answer
165 views

Error while calling function in smart contract using nodejs?

I have deployed a contract in private blockchain using mist wallet. When I try to call the function in the smart contract using web3 api it through the below error /home/karthikeyan/Desktop/n2/...
0
votes
1answer
147 views

Calling onlyowner functions using owner's private key

I need to call a function with onlyOwner modifier in my smart contract via web3.js. I want a user of my site to be able to send their information to a white list, but it sends the transaction from ...
0
votes
2answers
165 views

Can I deploy a smartcontract with web3 1.0, without the metamask popup?

I'm using web3 1.0 to programmatically deploy smartcontracts and make transactions, and metamask to sign those transactions, since i don't want to have hardcoded fragile things. I would like metamask ...
1
vote
3answers
301 views

Error: Number can only safely store up to 53 bits

const result = await myContract.methods.myMethod(1).call(); brings the error from above. There is a simmilar questions here but since I use call gas shouldn't matter. I'm using "web3": "1.0.0-beta.35"...
0
votes
1answer
186 views

invalid argument 0: hex string without 0x prefix

In order to get a list of transactions by account address I used the following code snippet - function getTransactionsByAccount(myaccount, startBlockNumber, endBlockNumber) { if (endBlockNumber == ...
0
votes
1answer
152 views

How to get currentProvider HTTP URL?

How do I get web3 currentProvider HTTP URL? I'm using web3 1.0.0-beta.34. I tried many functions and already looked at the docs - but still couldn't find the right way to get the URL of the current ...
0
votes
0answers
20 views

Sign a transaction locally and send it

I'm using Infura as my web3 provider, and have MetaMask installed to connect to the blockchain. I'm trying to send a transaction, but have learned that Infura is read-only, and doesn't support the ...
0
votes
2answers
195 views

web3 (then property) in ethereum node

Would you please help: When I run the below command in my nodejs console I get the below error: (I am using web3 0.20.0) on Windows 10 web3.eth.getAccounts().then(list => {accts = list}) ...
0
votes
1answer
25 views

Contract deployment using web3.eth.contract(abi) with constructor arguments

I'm trying to deploy the following smart contract: pragma solidity ^0.5.00; contract TestContract { address public owner; string public word; constructor(string memory _word) public{ ...
12
votes
7answers
7k views

TX doesn't have the correct nonce - Metamask

I'm trying to call the leafPicked() function in my contract from web3 which launches Metamask as intended. After pressing accept the transaction shows as failed along with the error message pictured ...
1
vote
1answer
151 views

Given transaction hash, how to proof that it was a successful erc-20 token transfer using web3?

I have a transaction hash and an RPC access to fully synced node. How to check if the token was actually moved? The transaction might be old, so there is no point in querying the contract. If I ...
0
votes
1answer
16 views

How to add actual Ether to custom token

I built a token by creating a smart contract for it, and have successfully connected to it, which is on a Ethereum test-net. Using web3.js I have been able to send token from one account to another ...
2
votes
0answers
19 views

Using web3.js, how can I get a TX hash before sending?

I'm using web3.eth.accounts.signTransaction() to obtain a rawTransaction, but I also need the transaction hash. calling web3.eth.sendSignedTransaction() will give me the hash, but I need to get it ...
0
votes
0answers
165 views

web3.admin api doesn't work in external JavaScript code

I'm trying to interact with a private blockchain from a JavaScript code, for that i've provided an RPC address to each node and extended multiple apis using -rpcapi . Now if I'm using geth attach http:...
0
votes
0answers
17 views

Web3.js in Docker: invalid JSON-RPC response: undefined

Recently I've made a container out of my app, which used to work fine in a normal environment with an infura node. This is the code that's causing problems inside of the Docker container. I'm new to ...
1
vote
2answers
165 views

web3.py provider error — 'Web3' has no 'eth' member

Hi I am trying to use web3.py to connect some python code to a solidity contract and I am getting an error -- Web3 instance has no eth member. w3 = Web3(EthereumTesterProvider()) ...
10
votes
6answers
11k views

Invalid Address Error when interacting with a smart contract with metamask

I want to call the methods with metamask of this simple contract: contract AssetPrices { mapping (uint => uint) public prices; uint public data; function EnterPrice(uint _time, uint _price){...
0
votes
0answers
9 views

How to use web3.bzz with PoA network?

I'm trying to use web3.bzz with a poa network but I always get this error : invalid content type, only application/json is supported this the code: const file = fs.readFileSync("file.json"); web3....
1
vote
2answers
227 views

Authenticate transaction in Web3.js application with password

I have a simple web3.js based app and like to call a method from an contract. For this method an authenticaten is needed. I found some examples in the web using web3.eth.accounts.signTransaction But ...
1
vote
4answers
2k views

Web3 - Cannot get accounts

I am trying to understand web3 better and tried out the following snipped: <script type="text/javascript"> if (typeof web3 !== 'undefined') { web3Provider = web3.currentProvider; ...
1
vote
1answer
34 views

How to call contract functions using web3?

I have deployed my contract in private blockchain, now I am calling functions using Nodejs and web3. Here, I want to transfer tokens for which I need to unlock my account from which I am transferring ...
0
votes
0answers
13 views

What is the role of the Geth ipc socket in a web3.js connection?

I started Geth as a root and try to run node.js with the rights of the group www-data. When node connects to Geth all is fine but transactions throw ... (node:27824) UnhandledPromiseRejectionWarning: ...
0
votes
0answers
11 views

How to generate Ethereum accounts using Web3 Python on Ropsten?

Just wanted to know how to use web3.py to generate Ethereum accounts. I tried using ropsten.infura.io/v3/<KEY> as an HTTPProvider, but it does not allows to create me account
0
votes
1answer
202 views

Couldn't decode uint256 from ABI: 0x

I'm trying to get all Transfer events from an account of an ERC721 token, I'm currently struggling with the following error. I googled around but couldn't find much helpful things. I'm definitely on ...
0
votes
1answer
16 views

Is geth account new and web3.eth.accounts.create the same?

For creating a new account, are these 2 commands the same or different? geth account new and web3.eth.accounts.create.
0
votes
1answer
162 views

Error while retrieving transaction count

I am trying to retrieve the total transaction count of an address using java, web3j and Infura as the Ethereum client. My code is as below: EthGetTransactionCount txnCount = web3j....
1
vote
2answers
169 views

Compile error when trying to import web3.swift

I am trying to import web3swift into one of my Swift files, but get the compiler error "No such module 'web3swift'". The import statements look like this: "Import Geth" "Import web3swift" In my pod ...