ReferenceError: Sonr01 is not defined - ethereum

when i deploy a smart contract on joerli testnet by using hardhat
i faced this eroor in final step to get an address for the block
ReferenceError:

Related

Error during solidity smart contract deployment : Uncaught Error: Callback was already called

Uncaught Error: Callback was already called.
at /home/blockchain/master/node_modules/merkle-patricia-tree/node_modules/async/lib/async.js:43:36
at WriteStream. (node_modules/merkle-patricia-tree/node_modules/async/lib/async.js:358:17)
at WriteStream.destroy (node_modules/level-ws/level-ws.js:140:8)
at finish (internal/streams/writable.js:670:14)
at processTicksAndRejections (internal/process/task_queues.js:80:21)
at runNextTicks (internal/process/task_queues.js:62:3)
at processImmediate (internal/timers.js:434:9)
Found out this to be a problem with node v14.x and ganache-cli v6.12.2 (ganache-core: 2.13.2).
Installing node v13.9.0 solved the issue for me.
in my case, reinstalling ganache-cli fixed it for me.
Install the latest version 7.0.3 of ganache instead ganache-cli
npm install --save-dev ganache
in code just use
const ganache = require('ganache');
const web3 = new Web3(ganache.provider());

Deployment Failed: project ID does not have access to archive state

I am trying to deploy my smart contract code in Infura using truffle, but this error has been raised
Deploying 'Migrations'
----------------------
Error: *** Deployment Failed ***
"Migrations" -- Unknown Error: {"jsonrpc":"2.0","id":6,"error": {"code":-32002,"message":"project ID does not have access to archive state","data":{"see":"https://infura.io/dashboard"}}}
{
"originalError": {}
}.
Any help
Thanks
It is weird.
I think it works if I skip the dry-run. But not sure why kovan-fork is not working. It was working yesterday.
You can change the network as you want
truffle migrate --network kovan --reset --skip-dry-run

Migration 2_deploy_contracts invalid or does not take any parameters at Object.run()

I am trying to compile my smart contracts using truffle pet-shop. I have the following contract in directory election/contracts/election.sol ;
pragma solidity >=0.4.0 <0.6.0;
contract Election{
string public candidate;
constructor() public{
candidate="Zeeshan";
}
}
The migration file to deploy contracts in directory election/migrations/2_deploy_contracts1.js is as follows;
var Election1=artifacts.require("election.sol");
module.export=function(deployer){
deployer.deploy(Election1)
};
I am using the following command to migrate the contracts:
truffle migrate
And I am getting the following results:
Compiling your contracts...
===========================
> Compiling .\contracts\Election.sol
> Compiling .\contracts\election.sol
> Artifacts written to D:\Notes\BCS\Semester 8\FYP\Practise Coding\dapp university 2 hr video code\election\build\contracts
> Compiled successfully using:
- solc: 0.5.8+commit.23d335f2.Emscripten.clang
Starting migrations...
======================
> Network name: 'development'
> Network id: 5777
> Block gas limit: 0x6691b7
2_deploy_contracts1.js
======================
Error: Error: Migration D:\Notes\BCS\Semester 8\FYP\Practise Coding\dapp university 2 hr video code\election\migrations\2_deploy_contracts1.js invalid or does not take any parameters
at Object.run (C:\Users\mk141\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\truffle-migrate\index.js:92:1)
at process._tickCallback (internal/process/next_tick.js:68:7)
Truffle v5.0.30 (core: 5.0.30)
Node v10.16.1
Its also compiling Election.sol because I renamed election.sol to Election.sol and it stores election.sol in cache perhaps.
As you can see above its giving Error:Migration 2_deploy_contracts invalid or does not take any parameters at Object.run() and i don't know how to resolve it.
I was making a mistake in 2_deploy_contracts1.js file. There is module.exports instead of module.export. So the new 2_deploy_contracts1.js file will be;
var Election1=artifacts.require("election.sol");
module.exports=function(deployer){
deployer.deploy(Election1)
};
Also, I was using the following command to migrate again;
truffle migrate
Instead, I should use the following command if I am migrating again;
truffle migrate --reset
We use this command because we already migrated our smart contracts in the built folder. This command will remove all previously migrated files in the built folder and add new migrated files of smart contracts.
In the require function you need to check the name of your contract like Election.sol and check for any typos

Error migrating truffle rinkeby [Cannot read property 'bind' of undefined]

I'm trying to deploy/migrate contract to rinkeby network, while using command:
truffle deploy --reset --network=rinkeby
It loads the keys and afterwards throws error:
C:\Users\marti\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\truffle-provider\wrapper.js:26
var originalSendAsync = provider.sendAsync.bind(provider);
TypeError: Cannot read property 'bind' of undefined
I'm able to run truffle develop without any issues
I'm also using:
truffle-hdwallet-provider
zappelin-solidity
Okay so the issue was comming from the truffle-hdwallet-provider version.
changing the ver from : 1.0.0-web3one.2
to : 0.0.6
solved the issue

Cannot deploy on rinkeby network using truffle

I'm trying to deploy simple crowdsale coin on the rinkeby test network. I'm using https://github.com/gustavoguimaraes/my-ico as template, where my code is at https://github.com/nmiculinic/shitcoin ; master commit; hash 599edc5d5a7d1c614d64fb43f96e19bdab9e8252
However I'm unable to get this simple coin deployed to the rinkeby test network (nor the gustav's one for that matter) with the following error:
shitcoin (master) ✔ truffle migrate --reset --network rinkeby
Compiling ./contracts/Shitcoin.sol...
Compiling zeppelin-solidity/contracts/math/SafeMath.sol...
Compiling zeppelin-solidity/contracts/ownership/Ownable.sol...
Compiling zeppelin-solidity/contracts/token/BasicToken.sol...
Compiling zeppelin-solidity/contracts/token/ERC20.sol...
Compiling zeppelin-solidity/contracts/token/ERC20Basic.sol...
Compiling zeppelin-solidity/contracts/token/MintableToken.sol...
Compiling zeppelin-solidity/contracts/token/StandardToken.sol...
Writing artifacts to ./build/contracts
Using network 'rinkeby'.
Running migration: 1_initial_migration.js
Replacing Migrations...
... 0x0bd42558d2daba72c886b369a492d1432397d9d617d14ce6655e1723b1d03058
Migrations: 0xb5b69afbaf45bdfb3e3fd73164259a6cd55d031a
Saving successful migration to network...
... 0xb3f5e8d87729e05b258fa97fda467d068e68c2903b60b8dc3989631c2e804262
Saving artifacts...
Running migration: 2_deploy_contracts.js
Deploying ShitCoinCrowdsale...
... 0x113fbb45883d804a6befe05d3fa9ef940ecc2ab02196abc830b5b994064e57cc
Error encountered, bailing. Network state unknown. Review successful transactions manually.
Error: The contract code couldn't be stored, please check your gas amount.
at Object.callback (/usr/lib/node_modules/truffle/build/cli.bundled.js:222830:46)
at /usr/lib/node_modules/truffle/build/cli.bundled.js:35149:25
at /usr/lib/node_modules/truffle/build/cli.bundled.js:224768:9
at /usr/lib/node_modules/truffle/build/cli.bundled.js:66971:11
at /usr/lib/node_modules/truffle/build/cli.bundled.js:208348:9
at XMLHttpRequest.request.onreadystatechange (/usr/lib/node_modules/truffle/build/cli.bundled.js:209773:13)
at XMLHttpRequestEventTarget.dispatchEvent (/usr/lib/node_modules/truffle/build/cli.bundled.js:67130:18)
at XMLHttpRequest._setReadyState (/usr/lib/node_modules/truffle/build/cli.bundled.js:67420:12)
at XMLHttpRequest._onHttpResponseEnd (/usr/lib/node_modules/truffle/build/cli.bundled.js:67575:12)
at IncomingMessage.<anonymous> (/usr/lib/node_modules/truffle/build/cli.bundled.js:67535:24)