A message from our CEO about the future of Stack Overflow and Stack Exchange. Read now.

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

Filter by
Sorted by
Tagged with
1
vote
1answer
8 views

Execute transaction Approve directly against contract address (without ABI)

await this.state.currentAddress.methods.approve("0x8b4a5682189361ce56702260051900f74d76e08b", amount).send({from: this.state.accounts[0]}); I have the following line in react. It is how I think I ...
0
votes
1answer
12 views

How to diagnose a “Error: Transaction has been reverted by the EVM”?

This the error intercepted from my javascript, using web3.js Error: Transaction has been reverted by the EVM: { "blockHash": "...
0
votes
1answer
20 views

send erc 20 tokens with full code example

I apologize for posting another question. Here I'm giving the full example code which is giving me the respond: "txHash undefined" when I try to send erc20. I want to fix this code. If you have even ...
0
votes
0answers
18 views

Error: connection not open on send()

I'm using "web3": "^1.2.4" This is how I connect to 'wss://kovan.infura.io/ws' const web3 = new Web3(new Web3.providers.WebsocketProvider('wss://kovan.infura.io/ws')) instance = new web3.eth....
0
votes
2answers
20 views

Project ID is required

I got an error at sendSignedTransaction is : Project ID is required. Can you please let me know that what is the actual problem? This is my code: try { const ethereumUri = 'https://ropsten....
1
vote
2answers
112 views

How is authorization handled in smart contracts

I have deployed a Quorum network on Azure Block chain service to be used by specific invited members of a consortium. I have not yet explored the privacy features provided by Quorum on top of Ethereum....
0
votes
0answers
16 views

Unfulfilled Promise From A Metamask Transaction

I'm having a problem with my JS code pausing on the let result line. Metamask prompts me to approve the transaction initiated in the line (which I do), but then doesn't proceed any further. As the ...
0
votes
1answer
18 views

How to resolve this error in solidity “The constructor should be payable if you send value.”?

In this solidity code the finalizeRequest() is giving a run-time error. Here is the error : Campaign.finalizeRequest(uint256) 0x692...77b3a transact to Campaign.finalizeRequest errored: VM error: ...
0
votes
2answers
9 views

What is the privatekey to be used to sign web3.js transactions?

I created an account on metamask, and downloaded the json of my wallet. It's on rinkeby. The structure of the json is { "version":3," id":"...", "address":"....", "crypto": {...
0
votes
0answers
21 views

Not able to call the solidity function through App.js? Anyone know how to call a solidity function?

I'm trying to call a Solidity function from App.js, but I'm unsuccessful even after a number of tries. Its a very simple function betOnTeam(). Inside this function I just want to check condition and ...
0
votes
1answer
18 views

How to call such a function? (pass argument)

For example, here is the code What will the best code practice, either to repeat the code inside two different functions or what can I do? OraclizeContract.deployed().then(function(instance) { ...
1
vote
1answer
16 views

How to send transaction using web3 contract instance from address which is not a node's account

I succeeded creating transaction from node's account(created by ganache) to a contract using web3.js . const contract = new web3.eth.Contract(abi, contractAddress, { from: from, gasPrice: ...
1
vote
1answer
23 views

callback vs on function in sendsignedtransaction

I am deploying a smart contract using web3js and it works perfectly. But i was made aware of my incorrect use of callbacks. I got some basic understanding of promievents from https://web3js....
1
vote
2answers
21 views

Node JS problem Interacting with Ethereum Smart Contract

I'm having only partial success with a Node.js script I wrote that interacts with one of my Ethereum Smart Contracts. Here's what's working: -I'm able to call methods in the Smart Contract from my ...
0
votes
1answer
13 views

Wrong version of web3.js

$ npm show web3 web3@1.2.5-rc.0 | LGPL-3.0 | deps: 8 | versions: 115 Ethereum JavaScript API https://github.com/ethereum/web3.js#readme ... $ node app/test.js VERSION { api: '0.18.4', node: [...
0
votes
0answers
21 views

Signing Ropsten transactions with

I am trying to sign transactions using the Web3 HDWalletProvider package and an infura API. I am using the following code: const Web3 = require('web3'); const Web3HDWalletProvider = require("web3-...
1
vote
1answer
20 views

Signing message with private key and verifying signer in smart contract

I have a smart contract that provides a message to sign and then validates the signer of the message. Something like: mapping(address => uint) public userNonce; function getSigner(bytes32 ...
0
votes
1answer
32 views

Function stopped working? No check is being done now on transfer function

I created a function to deposit and transfer ether and it was working great until i tried to deploy again and now the transfer function is not working anymore No errors are being thrown, the transfer ...
0
votes
1answer
23 views

getBalance of shows the wrong balance

I have this code to show the erc20 token balance of an account var tokenAddress = '0xb97E9bBB6fd49865709d3F1576e8506ad640a13B'; var walletAddress = '0x62f28320f688A7A4e0021c55d7ffD1acd770A133'; ...
0
votes
2answers
32 views

Cannot transfer ether from smart contract to another address

I am using truffle and when we type truffle develop it provides us with 10 address ** So, the problem I am facing is I have created 2 functions one to deposit ether and the other one to transfer the ...
0
votes
0answers
15 views

How is this possible using web3 and truffle accounts [closed]

all i want is this Alice sends contract 1 Ether. Now contract has 1 Ether. Contract forwards 1 Ether to Bob. Now contract has 0 Ether. I know this is possible but to accomplish it with front end AND ...
0
votes
1answer
26 views

cant call contract instances on my UI

I want to be able to display the read functions of my contract on a UI. These are the calls I make to my UI Those functions work perfectly in the console using node but when i try to call them from ...
0
votes
0answers
37 views

Whas this Error Code and how can i get rid of it?

Im using this code to query the balance of the logged-in address // get sellPrice function sellPrice() { web3.eth.getAccounts(function (error, accounts) { contract.sellPrice(address, ...
0
votes
0answers
18 views

How can I make function calls in UI based on these functions of my smart Contract [closed]

I want to call these functions as soon as an address is logged in to my UI Whats the best way to achieve this with metamask, web3 js?
0
votes
1answer
29 views

How can I access elements in Object?

I have my contract object and this has attributes like contract.balanceOf contract.myDividends contract.totalSupply contract.myTokens I get an error this._eth.call is not a function when i try to ...
0
votes
0answers
18 views

How can we send ether to smart contract address and then transfer it to a account? [closed]

Any ideas, code or suggestions is welcome I am using truffle ,web3 ,metamask Can we send rawtransaction to contract address and then Retrieved the amount? I need to deduct amount from 2 people ...
0
votes
2answers
32 views

How to access contract attributes?

I have initialized my contract and need to balanceOf the current logged in address const contract = new web3.eth.contract(abi).at(address); contract.balanceOf(function (error, balance) { $(...
0
votes
1answer
33 views

How to make Information automatically update when account is changed?

To get the account address of the contract that is currently logged in with Metamask I use this web3.eth.getAccounts(function(error, accounts) { document.getElementById('account-address')....
-1
votes
0answers
19 views

How to retrieve totalBalance of an ERC20 token contract? [closed]

Im using this to get the toalbalance of "AGI" in the contract https://ropsten.etherscan.io/address/0xe462cbee0cd420f6c199b0194b1d8d93fb5e7720#code window.addEventListener('load', async() => { // ...
0
votes
0answers
20 views

Transactions are failing randomly for multiple reasons when sending them in bulk for a benchmark

I'm trying to benchmark a private blockchain network (3 Vagrant nodes with 2gb of RAM running Geth Clique PoA, on an i7 7th gen Intel Core machine), following this process: A function launch n ...
0
votes
0answers
50 views

Cant call solidity function from app.js?

Solidity function Using web3 0.20 version and Cant call solidity BETONTEAM function pragma solidity ^0.4.22; import "installed_contracts/strings.sol"; import "installed_contracts/oraclize-api/...
0
votes
1answer
24 views

How can I get the current user account selected in MetaMask with Web3 js?

I'm using the next function to get the first account from user's MetaMask: var account = web3.eth.getAccounts((error,result) => { if (error) { console.log(error); } ...
-3
votes
2answers
58 views

How to get contract Balance of ERC20 TOken? [closed]

I have my smart contract here https://ropsten.etherscan.io/address/0xE462CbEE0cd420f6c199B0194B1D8D93Fb5e7720#writeContract I want to display the total token Balance of AGI inside my contract. My ...
0
votes
1answer
16 views

Error when connecting to web3 and metamask

I use this code to connect ui with smart contract window.addEventListener('load', () => { // Wait for loading completion to avoid race conditions with web3 injection timing. if (...
0
votes
0answers
28 views

how to “approve” function from another smart contract?

I need to first have my transaction approved by another smart contract before ic an use the token in my smart contract. How can i call this function from the UI using meatamsk? The contract is here ...
0
votes
0answers
17 views

How can i transfer ether upon callback from Oraclize/Provable? [closed]

I am a newbie any help is highly appreciated I know how to send call to oraclize finally, and how to transfer ether between two accounts using web3,metamask But How can i transfer this fund when ...
0
votes
0answers
29 views

Cant call solidity function from app.js while sending transaction

Solidity function As i want to call function so that oraclize can send query function betOnTeam(uint team) payable public { update(); emit LogInfo("Oraclize query was NOT sent, ...
0
votes
1answer
23 views

Can someone explain the difference between using metamask or web3 to send ether from truffle accounts?

I am using web3 and truffle (i am a newbie wants to understand concept) I need to transfer ether so i understand that i need to use web3.eth.sendtransaction But will it work as i am using localhost ...
0
votes
1answer
22 views

Can we take input of an address and pass it on the function to send ether using truffle and web3?

Actually i am trying to create a betting application so when i get the result that Home team has won Before this i will be taking both address as input (betting do two address whoever wins gets the ...
0
votes
2answers
22 views

How can i add smart contract to metamask?

I have a smart Contract that i need to hook up with metamask and my ui. https://ropsten.etherscan.io/address/0xe462cbee0cd420f6c199b0194b1d8d93fb5e7720#writeContract I have an exchange.js file ...
-1
votes
0answers
23 views

Can we take input of an address and pass it on the function to send ether using web3 and truffle? [closed]

Actually i am trying to create a betting application so when i get the result that Home team has won Before this i will be taking both address as input (betting do two address whoever wins gets the ...
0
votes
1answer
32 views

Getting stuck in truffle testing

I am trying to run a test and I am getting the following message; I have tried the following; npm install scrypt npm install web3 as to solve the yellow message and when running truffle test ...
0
votes
1answer
17 views

Storing name values off-chain in events and web3.js

Somewhere I read the advice to store name (title, geographical name, people name, etc.) value off-chain in events. But if a value is stored in an event, is there an efficient way to retrieve its ...
0
votes
0answers
47 views

How to call solidity function from javascript file? Keep getting error deploying through truffle and webpack

Error -> TypeError: fetch.amount is not a function [WDS] Disconnected! Please explain or provide code on how to call solidity function Trying to call from ready() function console.log(contract.abi)...
0
votes
2answers
74 views

why did this transaction fail?

I have a smart contract on Ropsten that I'm testing: 0x813870feba76f27ec1AfcF79432e065A4839F7AB Transaction has failed(reverted). What is the problem, because I don't see an error message ...
1
vote
1answer
20 views

Getting an 'invalid opcode' calling a solidty function from test file

im in the process of learning about ethereum and Solidity, and im having a problem calling a payable function from a test file. This is my contract pragma solidity >=0.4.22 <0.6.0; //pragma ...
0
votes
1answer
13 views

How can i deobfuscate JS code? [closed]

I want to learn how a ui is connected to a smart contract but unfortunatly the JS file is obfuscated and i cant read it. Is there a way to deobfuscate this file? The code can be found ehre https://...
0
votes
1answer
21 views

Getting error -> unexpected token. You may need an appropriate loader to handle this file type

root@kali:~/Documents/oraclize-test# npm run dev truffle-oraclize-api@0.0.2 dev /root/Documents/oraclize-test webpack-dev-server ERROR in ./app/javascripts/app.js Module parse failed: /root/...
1
vote
1answer
29 views

Invalid number value when deploying contract using truffle? But how to fix it in code is the value or _amount variable ?i cannot figure it out

2_deploy_contracts.js Replacing 'OraclizeTest' Error: * Deployment Failed * "OraclizeTest" -- invalid number value (arg="_amount", coderType="uint256", value={"from":"...
1
vote
1answer
43 views

Web3 is not defined - Require not found

I am trying to connect and interact with a local blockchain (using ganache-cli) through the web3js library. I have created a local website that uses web3js library but I keep getting the following ...