d1onys1us / dapp-slaps

A starter template for building Ethereum dapps. 👏
https://dapp-slaps.vercel.app
MIT License
167 stars 53 forks source link

Read and write throwing errors. Signal service working fine. #21

Closed shot-codes closed 1 year ago

shot-codes commented 1 year ago

Hey! First off, thanks for this. Very happy to have such a complete example of a dapp with sveltekit. I have cloned manually and everything seems to be working. However for both the read and write operations on the home page I get the following error in the console.

Uncaught (in promise) Error: call revert exception [ See: https://links.ethers.org/v5-errors-CALL_EXCEPTION ] (method="myString()", data="0x", errorArgs=null, errorName=null, errorSignature=null, reason=null, code=CALL_EXCEPTION, version=abi/5.7.0)

I do complete a transaction with metamask when I issue a write, and the transaction is confirmed thereafter. This happening locally, but also on ther instance you have deployed at dapp-slaps.vercel.app

Any help would be much appreciated :)

shot-codes commented 1 year ago

Ah, I realize now that I can only use that when I connec to the Foundry network. Is it possible to test without using ETH for gas?

d1onys1us commented 1 year ago

Ah, I realize now that I can only use that when I connec to the Foundry network. Is it possible to test without using ETH for gas?

hey @shot-codes thanks for stopping by, you're welcome! to test the basic Foo smart contract on the home page, you will need ETH to write to the contract. you will not need ETH however to read from the contract. but to read from the contract, you need to be connected to an ethereum node, and the contract needs to be deployed. so if you connect with the local foundry network, and deploy the contract, you can read it without using ETH. but to write to it, you will need to use ETH. keep in mind, this ETH is not real ETH, the foundry network can bootstrap your accounts with a bunch of testnet ETH to use.

let me know if you need any further help

shot-codes commented 1 year ago

Cheers, this makes good sense. Can you point me to where I can bootstrap the foundry ETH? Cant seem to find any info about it online

d1onys1us commented 1 year ago

Cheers, this makes good sense. Can you point me to where I can bootstrap the foundry ETH? Cant seem to find any info about it online

hey yes if you just start a local node by referencing the dapp-slaps README, you can use anvil -m $MNEMONIC where $MNEMONIC is an environment variable storing a BIP39 seed phrase. starting anvil with this mnemonic will initialize all of those accounts with a balance of like 100000 ETH or something. then, you will see in the log output the private key for each of the several accounts associated with the BIP39 seed phrase. you can copy one of those private keys (i.e., account #0) and just simply import that into metamask or your preferred wallet. then you will have an account you can use in your wallet which has some ETH when connected to the local anvil node at localhost:8545

shot-codes commented 1 year ago

Ah thanks, I completely missed the printout of all those private keys. Seems I'm almost there now. Following the readme I am able to deploy the contract and read from it, but get the following error in the browser console when trying to write to it.

Screenshot 2023-03-20 at 14 30 38
d1onys1us commented 1 year ago

Ah thanks, I completely missed the printout of all those private keys. Seems I'm almost there now. Following the readme I am able to deploy the contract and read from it, but get the following error in the browser console when trying to write to it.

Screenshot 2023-03-20 at 14 30 38

can you try out the Troubleshooting section from the README? I had this issue too, and i can't completely answer why it happens. But, i'm pretty sure it's that metamask is somehow getting out of sync with the block height. let me know if those troubleshooting steps help... if it does, i'll specifically add this error in there to help others out w/ it.

shot-codes commented 1 year ago

I didn't get the chance to troubleshoot. Simply getting everything up and running again had it working. If I run into it again I will let you know. One further question; It seems in my testing that I might have killed my local node or something along those lines while an account was processing a transaction. It appears to be stuck pending, no matter if I launch a new node or not. It's not really an issue as I can just use on of the other accounts, but curious if there is a way around this?

d1onys1us commented 1 year ago

@shot-codes yeah I had this too. When I used metamask. try to reset the account in metamask and I think it will work. There's something up with metamask and foundry that doesn't play nice (I think)

shot-codes commented 1 year ago

Did the trick :)