Skip to content
Advertisement

Tag: smartcontracts

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

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

Uncaught (in promise) Error: invalid address

how to fix this error when i call a smart contract function? it’s my code: Answer The Problem The error shows that you didn’t set the address property correctly, it’s may be the issue with your solidity implementation and it’s not related to javascript snippet, as mentioned in the comments, you can ask about it on related sites, but there

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

Importing ethers via Hardhat fails despite official testing documentation

According to the official testing documentation for Hardhat, ethers should be available implicitly within the global scope; however, it can optionally be required explicitly, like so: This fails for my local project. My package manifest seems to include the correct dependencies: My unit tests file seems to match the worked example in the Hardhat documentation also: Despite this, running the

How to send an ERC20 token with web3js

I’m currently using the 0.2x.x version of the 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

Advertisement