New answers tagged

0

I think this Reddit thread might help :)


0

You are declaring accounts as an empty array: thus accounts[0] will be null. either declare it manually, or use this


0

Update Solved my own problem. I moved all of the logic to a different file. Exported the function and imported it into my controller. Worked perfectly.


0

Ok so I have eventually figured it out! Was really simple, I had the wrong network, should have been "rinkeby" and not "homestead". Homestead is the mainnet and I am still in test mode. It's still a little laggy to show the numbers, but does the trick. Maybe this'll help someone in the future!


0

For me, the error came up because I was deploying my contract with an eth value greater than what I had in my Metamask wallet. My total wallet balance was 0.9 ETH and I was trying to deploy with 1ETH : var contract = await contractFactory.deploy({value: hre.ethers.utils.parseEther("1")}); changing the value to 0.07 solved it: var contract = await ...


1

I had a folder named smart_contracts. Inside of it I created a folder named hadhat_typescript_sample and communicated with the latter via smart_contracts/ I fixed that error by opening hardhat_typescript_sample in VsCode. Hopefully, it will help you out:)


0

For anyone finding this thread in the future Apart from current maintenance this is the reason according to Quicknode customer support: First, no provider is capable of seeing the ENTIRE mempool at all times. It's a p2p network and the mempool is not consistent across all endpoints at all times. There are even private mempools and peers that do not ...


4

In Solidity you can ignore one or all of the returned values by just not assigning them to the variables: (uint a, ) = xyz(); The code above would only get the first returned value and ignore the second one. (, uint b) = xyz(); This code would only get the second returned value. uint256 c; function abc() public { (uint a, ) = xyz(); c += a; } This is ...


1

You might try popping this in the geth console, tweaking the block production rate for your chain of interest: (function() { const secPerSample = 10; const sampleWindow = 100; const networkBlocksPerSec = 1 / 2.3; // network block time (polygon makes a block every ~2 seconds) const dataPoints = []; var topBlock = eth.syncing....


0

Solved this by using ethers.utils.id(JSON.stringify). Though I'd like to know how to do this manually without using the id function if anyone has any insights on this.


0

Use the accountschanged event. ethereum.on('accountsChanged', handler: (accounts: Array<string>) => void);


0

You need to approve, yes. In solidity, just is this: IERC20(address(token)).approve(address(router), amountToApprove); So, you just need to convert it to the language you are using, if you are not using solidity. In ether.js, what I suppose you are using, check this: Execute transaction Approve directly against contract address (without ABI)


0

I developed my contract using ECDSA I have no idea what you are trying to say by that and I am certain that you are just expressing yourself wrong here ;) You wrote a contract using solidity, right? Let's get back to the original question: Security of private key. As you already stated, you can't keep your private key in the frontend. Anyone would be able ...


1

Yes. You could examine the headers from the webserver/IPFS server which will often indicate the type of the object in the stream. Alternatively you could use magic numbers


0

Simply run npm i @truffle/contract this will install the right package. trufle-contract is now renamed to @truffle/contract. Check npm docs


1

The problem is with VS Code Solidity Extension. The video will help you solve it. https://youtu.be/5qTdQNCMwk8


0

I just changed options to: var options = { gasLimit: 850000 }; And it works now.


2

Essentially because you are already using an abstraction layer that gives you what you need, when you need, giving you fresh values when called. It's up to the abstract instance of the contract (loanApp in your case) to work behind the scene, call the node via RPC to know the state and send back the result to you. And this is why you need await and you ...


0

There is a way to do it. You will have to create a domain that will allow HTTPS (Vercel is an example) host your MM code on the HTTPS site. On wix create a HTTPS iframe, and embed the site that host your MM code. I did it for a project that was on a Wix site. In this instance, I used Bubble's Web3/MM functionality and embedded it to this site: www....


0

For this it is important to understand how function calls are encoded. The first part is to calculate the function selector. This is a 4byte identifier of the method that starts the calldata. (See https://docs.soliditylang.org/en/v0.8.11/abi-spec.html?highlight=Function%20id#function-selector). For you example the function selector would be the keccak hash ...


0

When triggering solidity methods you don't always get the returned values back to your JS environment. For call methods (e.g. view) - functions that do not change state, you can reliably expect return values. Whereas for write methods - those that change state, your JS library will not expect them by default. This is due to the unknown time of mining the ...


0

That depends on the service you use to upload the files. They may have different requirements, but the end result is the same. Using buffers/streams is mostly useful if you're dealing with lots of data and/or in an environment where memory is limited. Streaming data means you don't transfer all at once, but send smaller pieces all the time. That wait the ...


0

with ethers or web3js, you'll be able to interact with contracts from your frontend. if you're using plain javascript, you can use cdn links to import respective libraries. shown below with ethersjs const provider = new ethers.providers.Web3Provider(window.ethereum); const signer = provider.getSigner(); const contract = new ethers.Contract(address, abi, ...


0

Use deployedContract = await ethers.getContractAt("ContractName", ContractAddress);


1

There is a getter automatically generated, but it is not the js array accessor. If you look at the generated ABI you can see the folowing method: { "inputs": [ { "internalType": "uint256", "name": "", "type&...


0

deploy() will trigger this deployment of the contract and .deployed() checks if the contract is already available on the blockchain and if the deployment is still ongoing will wait for the deployment transaction to be mined (see https://github.com/ethers-io/ethers.js/blob/master/packages/contracts/src.ts/index.ts#L819).


0

The difference is that in the first transaction you are approving yourself MethodID: 0x095ea7b3 [0]: 000000000000000000000000b78314255250be3f4cfcba6205d1c1d02b06aba5 [1]: 0000000000000000000000000000000000000000000000003782dace9d900000 And the Pancake UI is approving the Pancake Router contract https://bscscan.com/address/...


1

It isn't implemented automatically so it is only if the specific contract that created the nft implements it. You need the contract address that created the nft, then you can inspect the code to see if it has something like a tokenIdToOwner mapping.


0

None of these answers worked for me until I used the following, including the provider, the signer, and getting the contract instance: const provider = new ethers.providers.JsonRpcProvider() // using default http://localhost:8545 const signer = new ethers.Wallet(privkey, provider) const myContract = await ethers.getContractAt('MyContract', contractAddress, ...


1

Exposing an RPC from an existing script can be done by calling the node task. Make sure you've setup forking for hardhat in hardhat.config.ts Create a new script file to run at start.js with the code: async function start() { const { run } = require("hardhat"); // deploy your contact here await run("node"); await new Promise(() =>...


Top 50 recent answers are included