1

I have a simple smart contract that I deploy to my own geth node and it works fine but the problem is when I close the geth console and start it again I have to redeply the smart contracts again Here is the code I am using to start the geth node

geth --port 3001 --networkid 5777 --datadir=./node1 --maxpeers=50  --rpc --rpcport 8545 --rpca
ddr 127.0.0.1 --rpccorsdomain "http://localhost:3000" --rpcapi "eth,net,web3,personal,miner" --allow-insecure-unlock con
sole 2>>eth.log --mine  --miner.gasprice 0   --syncmode 'full'

Am I missing something ?????

EDIT: It is a SimpleStorage Contract, I can get the value after restarting the node but when I try to set it , it doesn't work

EDIT2: I tried using ganach and it worked perfectly as expected, So I am almost certain that I have a problem with geth

0

It would help if you ran it as a daemon, when starting Geth, put a & at the end of the command.

You should add --gcmode archive to avoid a further problem with the garbage collector https://ethereum.stackexchange.com/a/80062/49141

The solution is to use --gcmode archive, it disables the garbage collection and keep all the historical state data since the Genesis.

| improve this answer | |
  • It didnt work unfourtualtly :( – MTG Feb 25 at 15:52
  • Please give us some outputs to help you debug the case. How exactly do you try to invoke your smart contract? You can try to open a new terminal and run the below command: geth attach http://127.0.0.1:8545 – Adam Boudjemaa Feb 25 at 16:22
  • I am using truffle to deploy the contract and this is the code (NodeJs) I am using to set the value: let encoded = method(...args).encodeABI(); var tx = { gas: "53528", gasPrice: "0", data: encoded, to: contractAddress, ...options }; const signed = await web3.eth.accounts.signTransaction(tx, privateKey); const result = await web3.eth.sendSignedTransaction( signed.rawTransaction ); – MTG Feb 25 at 16:41
  • I just tried running the code with Ganach and there is no problems at all. I dont think the problem is with NodeJs code but with geth settings that I am using – MTG Feb 25 at 17:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.