How to load web3 correctly ? this is my code: Answer window.web3 is deprecated. easies way is to use @metamask/detect-provider npm package
Tag: web3js
Can I generate a transaction on the server and send it to the client for payment
I have built a smart contract method to which I pass some sensitive data that needs to be stored on the blockchain and alter the state of the contract. I, the creator of the contract don’t want to be the one paying for the fees of that transaction. I want the user on the browser to approve and pay for
Decode constructor arguments in solidity
I playing Ethernaut Level 8. The goal is to get access to the private password state variable and unlock the contract. I know one could use await contract.unlock(await web3.eth.getStorageAt(contract.address, 1));, but I want to find the password decoding the input data of the contract creation. Here is the contract. I tried await contract.unlock(“f94b476063b6379a3c8b6c836efb8b3e10ede188”) but that didn’t work. Answer If the
Command ‘Solidity: Compile Contract’ resulted in an error (Cannot read properties of undefined(reading ‘uri’))
Good day everyone, I am working on a lottery smart contract. I am currently done with the remix VM tests and proceeded with the unit tests with JavaScript. The test.js file is shown below. The test file for now only checks if the contract deploys, pretty simple. However, I have not been able to proceed from here due to a
How to configure to handle CORS errors in web3 connecting to ganache
I have a react project I am running at http:\localhost:3000 which connects to ganache running at http:\localhost:7545. I deploy a small smart contract onto ganache which increments a counter and emits an event, like this… I want to listen to the Pinged and Ponged events from my contract. As this is just a helper project for something else I am
Issue in calling a smart contract function with web3
I’m trying to call the createCustomer function provided in this smart contract https://ropsten.etherscan.io/address/0xD3B462CbF6244ed21CD3cF334Bf8CB44A28795A9#code and we basically have to provide three parameters like string memory _hashedEmail, string memory _name and string memory _phone. So I’ve written the following program to call the createCustomer function However it gives me this err which doesnt make any sense as i’ve already provided the three
Calculate Value from JS Promise
I have assigned a callback function to a variable. The function then returns a promise stating it is fulfilled and the value. I want to be able to return the value and use it to perform a mathematical calculation. Javascript code: In the console I get the below output. Answer Assuming this is the interface you’re using, this is an
Provided Address is invalid, the capitalization checksum test failed
I am trying to send a method on a contract using web3. I’m creating an account using the privateKeyToAccount method but when sending the method on the contract I get the following error: Provided address [object Object] is invalid, the capitalization checksum test failed, or it’s an indirect IBAN address which can’t be converted. Am I missing a step? I
Supply ETH to Aave through solidity
I’m trying deposit into Aave V2 Contract Aave’s Code Examples I have code which consumes this like so: When attempting to supply, Metamask displays an error: ALERT: Transaction Error. Exception thrown in contract code. And just a simple button to call it in html: I’m running ganache ganache-cli –fork https://mainnet.infura.io/v3/{{MyProjectId}} The only error I see in the console is: Transaction:
Not including ‘gas’ or ‘gasPrice’ attributes in the ‘options’ object inside of a send() call
Does anyone know what the send() function call to a smart contract method defaults to when you don’t specify gas or gasPrice? Does it automatically allocate sufficient gas and calculate the current average gasPrice? And are those attributes always optional or are there situations where including either one is mandatory? Answer From the documentation, both gas and gas seem to