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
2answers
42 views

web3 - call a variable, wait, get variable, wait, loop, get vars in loop, wait and do action [closed]

In my contract there are 2 functions, the first one returns an array size and other one returns data from the array with index passed as a parameter. In my web3 script I'm trying to read array size ...
2
votes
1answer
65 views

Web3JS incorrect return value

When I return a string array with web3 I don't get the original array as expected, but rather I get an array of the same size, with the index off by one. So instead of ["One","Two","Three"] I get ["",...
1
vote
2answers
24 views

Is it possible to interact with a contract deployed within another contract via web3js?

Be very helpful to know if the scenario below is possible contract A { import "./B.sol"; ... address c = new B(); b = B (c) } //somewhere in JS instance_of_B = web3.eth.contract(B.abi).at(c);
1
vote
1answer
51 views

how to use toWei() function in web3.js for tokens having 2 decimals?

I am trying to convert amount in wei using web3js function called toWei(). Here is my code: var etherwithdrawamount1=web3Infura.utils.toWei(etherwithdrawamount, 'wei'); Now, the problem is that ...
2
votes
0answers
51 views

Quorum :- metamask do not support privateFor feature of quorum

i got to know that metamask do not support privateFor because of which private transaction for quorum dapp was not behaving as expected. so, I can't use metamask for my quorum DApp to switch port and ...
0
votes
1answer
25 views

Script For Emptying Address

Does anyone have a script that can be used to transfer all ether found in an address to another address? The script will constantly check for any incoming ether and make an automatic transaction, ...
2
votes
1answer
47 views

web3: How does deploy new contract work? Can attacker fake my worker contract?

In the following documentation: https://web3js.readthedocs.io/en/1.0/web3-eth-contract.html it says that in order to create a new contract from my script with web3 I have to use the "new" keyword and ...
1
vote
1answer
38 views

Smart Contract byte code using web3

How Could I pull out smart contract bytecode using web3 and contract address?
1
vote
1answer
22 views

Event firing before data is actually set [Testnet]

Today I've faced the behavior similiar to this post. Event firing before data is actually set I'm getting events using infura and then checking for the state. I expect to read updated blockchain ...
0
votes
1answer
86 views

Error: gas required exceeds allowance or always failing transaction when trying to estimate gas

I am trying to run estimateGas function on mainnet like the following to send erc721 cryptokitties from one account to another: data.from = <my address> data.to = <destination address> ...
0
votes
1answer
41 views

Using Coinbase ETH Wallet to save contracts/send transactions with web3

I am working on a node app where I am using web3, Infura & truffle-hdwallet-provider & a new MetaMask wallet. This process appears to work & I can successfully deploy contracts! I want to ...
1
vote
1answer
56 views

Decrypting an account from keystore generates the error - Cannot read property 'kdf' of undefined

I need to sign a transaction and send to infura using a keystore. I ran into the following error while calling the decrypt function. if (json.crypto.kdf === 'scrypt') { ^ TypeError: ...
0
votes
2answers
62 views

Returning error message from smart contract

I am trying to return error messages from solidity. I have this contract: pragma solidity ^0.4.23; contract Simple { function arithmetics(uint a, uint b){ require(...
0
votes
1answer
42 views

How to avoid transactions getting queued due to one low gas transaction?

When executing a smart contract through one owner account, and if one transaction gets stuck( due to low gas price), all the other transactions submitted after that becomes pending. Is there any well-...
1
vote
6answers
193 views

How to get all contracts deployed by the address, given the address?

I want to get addresses of all instances of Contract X deployed by Account Y. How can I do that? I have to do it programmatically and fastest possible way.
2
votes
1answer
163 views

TypeError: web3_1.default is not a constructor

I'm trying to convert a DApp that uses web3.js from JavaScript to TypeScript, but I have encountered a bunch of runtime errors. I'm using Visual Studio Code IDE, and I'm compiling to ES6. I've reduced ...
0
votes
1answer
28 views

What is the change in smart contract when the 'chain reorganizations'?

Recently I learned about 'chain reorganization'. What is the change in smart contract when the 'chain reorganizations'? for example, contract Contract{ event LOG_Increase(); uint sum = 0; ...
0
votes
1answer
31 views

Finding the memory position of mapping(address => uint) using JavaScript

I am wanting to read data from internal mappings with the following structures: mapping (uint256 => uint256) internal nums; mapping (address => uint256) internal addrToInt; Finding the memory ...
0
votes
1answer
50 views

Web3js send ERC20 token with my own mining machine

Is it possible to send custom ERC20 token using my own mining machine? We have a big website where we are going to use our own Custom token but the problem is when we send tokens to the user we need ...
1
vote
1answer
22 views

Solidity, push overrides array [duplicate]

pragma solidity 0.4.24; contract ArraysExample { uint[] numbers; function addUser() public returns (uint[]) { numbers.push(random()); return numbers; } function random() ...
1
vote
1answer
47 views

What should I call the object returned from a Truffle contract function-call

When I perform a contract function-call via Truffle, and then resolve the returned promise, I get something like this: { "tx": "0x...", "receipt": { "transactionHash": "0x...", ...
1
vote
3answers
128 views

WEB3JS CORS ERROR

I have a empty html file that call to a js file. Inside that file I have this coded. if (typeof web3 !== 'undefined') { web3 = new Web3(web3.currentProvider); } else { // set the provider you ...
1
vote
1answer
88 views

Launch MetaMask login window by JS

I have installed MetaMask extension for Chrome, then I saw ext icon at top toolbar. To login I will open it by click on the icon. There is a question... Is there a way to launch MetaMask window by ...
0
votes
1answer
46 views

How to refund a wallet address from a contract with solidity and web3

I am building an app where I'd like a purchaser to be able to seek a refund from the contract. Essentially I am trying to transfer eth from a contract to a wallet. When I get to the point of issuing a ...
1
vote
1answer
47 views

Error: Invalid number of arguments to Solidity function when calling safeTransferFrom function

I want to call the safeTransferFrom function to transfer ERC721 tokens. I am using the following code: var contract = this.web3.eth.contract(JSON.parse(contractabierc721)).at(contractAddress); // ...
0
votes
2answers
29 views

Switch between accounts to run smart contracts

I'm using truffle develop to test my smart contracts. I've tried to switch between different accounts using web3.eth.defaultAccount = web3.eth.accounts[1] but had no success. How do I accomplish that?
2
votes
0answers
24 views

What Web3JS method do I call to know what value to use for the gas price with sendSignedTransaction?

I am using Web3JS 1.0+ to send transactions to my smart contract. I've been using the following constant for the gas price in my code that I got a long time ago from a tutorial. What is the "...
0
votes
1answer
34 views

How would you generate this transaction hash?

let contract = await instance.mint( accounts, usersInput.url, usersInput.metadata[0], usersInput.metadata[1], usersInput.metadata[2], { ...
2
votes
0answers
30 views

web3 - get all contract public variables?

I have an abstract worker contract and few that inherit from it. Those contracts have some public variables, each one different. I want to display them on my website. Is there any way to return all ...
-1
votes
0answers
86 views

ERC-20 Token Transfer Error (Unable to locate Corresponding Transfer Event Logs), Check with Sender when trying to send ERC721 tokens

I am trying to transfer ERC721 tokens from one account to another on Ropsten network. I do this by creating raw transaction, signing and broadcasting transactions I created the transaction this way {...
1
vote
0answers
30 views

Does web3 soliditySha3 work with json object?

The above hash data is generated by web3 soliditySha3 with the objects below. It seems the function generates hashes as I wanted; each object has different hash value. But I am not sure if it's ...
1
vote
1answer
17 views

Can't approve a transaction via uport though i have balance.what is the reason?

I am using rinkeby network. I am try to save a information to rinkeby network.but a popup apera to sign or approve the transaction via uport. i have balance but i can't sign the transaction. ...
1
vote
1answer
47 views

Web3 sending TX times out after 280 seconds because network lag

When I submit a transaction via web3 and metamask, it will await 280 seconds before timing out and returning the transaction receipt. How can I catch this error and handle with it so that my app can ...
-1
votes
0answers
37 views

Voting contracts and inheritance - returning variables

I have a simple voting system in my contract which is another contract and it looks more or less like this so far: contract BaseVoting { bool public alive; address private m_Platform; // ...
0
votes
1answer
53 views

Can't install web3

I am having a hard time installing web3 js via npm. I am on Windows 10 PRO and I have the Windows build tools installed. (These build tools are required to compile the infamouse native packages). ...
1
vote
1answer
38 views

Information lost when getting string from byte32 Solidiy smart contract

I have a number as a string which I pass to smart contract function as a parameter. The function takes byte32 as a parameter. Here is the node.js code for executing the contract function: const app =...
0
votes
1answer
24 views

Miner APIs are not found in web3.js package

How can I start and stop miner( miner.start(), miner.stop()) from my DApp if Miner APIs are available in web3.js package? I am using web3 v0.20.6.
0
votes
1answer
30 views

Execution of sending transaction never ends [UPDATED]

I send a transaction with web3 1.0.0 from a script like: async function sending(deployed_contract) { await deployed_contract.methods.mymethod(1).send({from: account}) .on('...
0
votes
0answers
28 views

web3.eth vs web3.eth.personal methods

I noticed there's a lot of common methods in web3.eth and web3.eth.personal objects for example web3.eth.sendTransaction() and web3.eth.personal.sendTransaction(). How do they defer? and which one ...
1
vote
1answer
126 views

Creating raw transactions for sending ERC721 tokens

I was able to create raw transactions for eth following this article https://medium.com/blockchain-musings/how-to-create-raw-transactions-in-ethereum-part-1-1df91abdba7c However, how can I create raw ...
1
vote
1answer
39 views

How to send signed transactions concurrently via Infura?

I'm using web3js and web3js-raw as follows to change state of my smart contract on ethereum, let initiateAddLoyaltyTransaction = function (fromWallet, toWallet, companyName, amount, callback) { let ...
0
votes
1answer
30 views

What is the corresponding web3 type to solidity bytes when using Typescript?

I want to call a solidity function a passing a parameter bytes b. function xyz(address a, bytes hexData) We front end code in Typescript is like that if (hexData) { let hexDataInBytes = ...
0
votes
0answers
34 views

Controlling access to functions with VIEW visibility with signed transactions?

Controlling access to functions that require ETH is straight forward because you get an address you can trust because it has been signed and verified, and therefore upi can use for access control ...
0
votes
2answers
39 views

Load testing Parity Node

After I finished my single node PoA setup, I wanted to test how many TPS it can handle. During the load testing, I noticed that the transactions have stopped mining. Instead, I am getting "...
1
vote
1answer
16 views

Accessing the Ethereum State Variables using web3js (Java Script)

I'm trying to run the below code to get the state variables using the getIdBytes method of the Smart Contract, and assign it to a java script array variable, but it doesn't seem to work. All I can ...
0
votes
1answer
27 views

ecSignHashAsync() giving INVALID_SIGNATURE Error

I'm trying to create an order in 0x but when I try to sign the order I get INVALID_SIGNATURE error? I'm using 0x version 2 onSubmit = async (event) => { event.preventDefault(); const { ...
0
votes
2answers
38 views

web3 returns 0x0000000000000000000000000000000000000001 as an address

I'm trying to create an asset in a smart contract using MetaMask and web3.js: contract AssetTracker { struct Asset { string name; string description; string manufacturer; ...
0
votes
1answer
23 views

Mycontract.deploy().send() does not work

I am trying to deploy a contract with web3 1.0.0 like: myContract.deploy({}) .send({ from: '0x1234567890123456789012345678901234567891', gas: 1500000,z gasPrice: '20000000000000' }, ...
0
votes
1answer
14 views

if I use parity -d “path” to sync with a modify path.will i type -d again when next time open parity?

this is my first time to use parity, so if i just type parity -d \abc to sync in the folder named abc. and should I type it again the next time I use the rpc service with parity? if not, will it sync ...
1
vote
1answer
131 views

Get ERC721 token total supply using web3.js

I created a simple contract which basically does nothing but mints new ERC721 tokens. The solidity code for it is as follows: struct Monster { string name; uint level; uint ...