Problems about 53 bits deploying contracts with Truffle - blockchain

I am trying to deploy a Smart Contract with truffle 5.1.19 as follows:
pragma solidity 0.5.16;
contract Simple {
string public message;
function Hello(string memory _initialMessage) public {
message = _initialMessage;
}
function setMessage(string memory _newMessage) public {
message = _newMessage;
}
}
When I run a truffle deploy --network mired I have the next error:
Error: Number can only safely store up to 53 bits
at assert (/usr/local/lib/node_modules/truffle/build/webpack:/node_modules/bn.js/lib/bn.js:6:1)
at BN.toNumber (/usr/local/lib/node_modules/truffle/build/webpack:/node_modules/bn.js/lib/bn.js:506:1)
at Object.hexToNumber (/usr/local/lib/node_modules/truffle/build/webpack:/node_modules/web3-utils/src/utils.js:234:1)
at Method.outputBlockFormatter (/usr/local/lib/node_modules/truffle/build/webpack:/node_modules/web3-core-helpers/src/formatters.js:236:1)
at Method.web3.eth.getBlock.method.outputFormatter (/usr/local/lib/node_modules/truffle/build/webpack:/packages/interface-adapter/dist/shim/overloads/ethereum.js:37:1)
at Method.formatOutput (/usr/local/lib/node_modules/truffle/build/webpack:/node_modules/web3-core-method/src/index.js:163:1)
at sendTxCallback (/usr/local/lib/node_modules/truffle/build/webpack:/node_modules/web3-core-method/src/index.js:473:1)
at /usr/local/lib/node_modules/truffle/build/webpack:/node_modules/web3-core-requestmanager/src/index.js:147:1
at /usr/local/lib/node_modules/truffle/build/webpack:/packages/provider/wrapper.js:112:1
at XMLHttpRequest.request.onreadystatechange (/usr/local/lib/node_modules/truffle/build/webpack:/node_modules/web3-providers-http/src/index.js:96:1)
at XMLHttpRequestEventTarget.dispatchEvent (/usr/local/lib/node_modules/truffle/build/webpack:/node_modules/xhr2-cookies/dist/xml-http-request-event-target.js:34:1)
at XMLHttpRequest._setReadyState (/usr/local/lib/node_modules/truffle/build/webpack:/node_modules/xhr2-cookies/dist/xml-http-request.js:208:1)
at XMLHttpRequest._onHttpResponseEnd (/usr/local/lib/node_modules/truffle/build/webpack:/node_modules/xhr2-cookies/dist/xml-http-request.js:318:1)
at IncomingMessage.<anonymous> (/usr/local/lib/node_modules/truffle/build/webpack:/node_modules/xhr2-cookies/dist/xml-http-request.js:289:47)
at IncomingMessage.emit (events.js:203:15)
at endReadableNT (_stream_readable.js:1145:12)
at process._tickCallback (internal/process/next_tick.js:63:19)
Truffle v5.1.19 (core: 5.1.19)
Node v10.19.0
My truffle-config for my network is the next one:
mired: {
host: "10.xxx.xxx.xxx",
port: 8080, // Custom port
network_id: "*", // Custom network
gas: 0, // Gas sent with each transaction (default: ~6700000)
gasPrice: 0x0, // 20 gwei (in wei) (default: 100 gwei)
from: "0x8...............", // Account to send txs from (default: accounts[0])
// websockets: true // Enable EventEmitter interface for web3 (default: false)
},
Doing a downgrade of my truffle to the 4.1.15 version this error dissapears but I don't understand why with an actual version, this error appears. Thanks in advance

If you are working with quorum like it is my case. On truffle-config.js, you have to write type:"quorum" and it solves the problem.

Related

What mean by Block limit ? I am getting ran out of gas error

"OverAll" ran out of gas (using a value you set in your network config or deployment parameters.)
Block limit: 6721975567 (0x190a9350f)
Gas sent: 6721975 (0x6691b7)
at C:\Users\saich\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\deployer\src\deployment.js:364:1
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at Migration._deploy (C:\Users\saich\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\migrate\Migration.js:68:1)
at Migration._load (C:\Users\saich\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\migrate\Migration.js:55:1)
at Migration.run (C:\Users\saich\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\migrate\Migration.js:171:1)
at Object.runMigrations (C:\Users\saich\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\migrate\index.js:150:1)
at Object.runFrom (C:\Users\saich\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\migrate\index.js:110:1)
at Object.run (C:\Users\saich\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\migrate\index.js:87:1)
at runMigrations (C:\Users\saich\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\core\lib\commands\migrate.js:269:1)
at C:\Users\saich\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\core\lib\commands\migrate.js:231:1
Truffle v5.1.39 (core: 5.1.39)
Node v16.13.0

Encountered an error while attempting to update latest block

I'm new to blockchain and i was just trying to deploy a simple smart contract to ropsten test net. I've used the smart contract code from https://github.com/t4sk/solidity-multi-sig-wallet. Also i'm using the account provided by truffle develop
My truffle-config.js:
networks: {
development: {
host: "127.0.0.1", // Localhost (default: none)
port: 8545, // Standard Ethereum port (default: none)
network_id: "*", // Any network (default: none)
},
ropsten: {
provider: () => new HDWalletProvider(mnemonic, `https://ropsten.infura.io/v3/${infuraKey}`),
network_id: 3, // Ropsten's id
gas: 5500000, // Ropsten has a lower block limit than mainnet
confirmations: 2, // # of confs to wait between deployments. (default: 0)
timeoutBlocks: 200, // # of blocks before a deployment times out (minimum/default: 50)
skipDryRun: true // Skip dry run before migrations? (default: false for public nets )
},
mocha: {
timeout: 100000
},
compilers: {
solc: {
version: "0.5.1", // Fetch exact version from solc-bin (default: truffle's version)
// docker: true, // Use "0.5.1" you've installed locally with docker (default: false)
// settings: { // See the solidity docs for advice about optimization and evmVersion
optimizer: {
enabled: false,
runs: 200
},
// evmVersion: "byzantium"
// }
}
},
Im using solidity: 0.5.1
But when i try to deploy it using truffle migrate --network ropsten im getting the following two errors
1.
This version of µWS is not compatible with your Node.js build:
Error: Cannot find module './uws_win32_x64_72.node'
Falling back to a NodeJS implementation; performance may be degraded.
1_initial_migration.js
======================
Deploying 'Migrations'
----------------------
> transaction hash: 0x673a9a02662595075c6f3aa4dc904d24203cb8e460a3e20a630869c5155cb78c
> Blocks: 2 Seconds: 53
> contract address: 0xde674E126884c8F7Ddd94B5013065596b81fEd6d
> block number: 12075322
> block timestamp: 1647065140
> account: 0xC10352218af6Ccbb574Fd0912adcc9Ac59C22950
> balance: 1.830076836873988898
> gas used: 175087 (0x2abef)
> gas price: 2.500000028 gwei
> value sent: 0 ETH
> total cost: 0.000437717504902436 ETH
Pausing for 2 confirmations...
-------------------------------
C:\Users\coolg\Desktop\hd_wallet\node_modules\request\request.js:848
var e = new Error('ETIMEDOUT')
^
Error: PollingBlockTracker - encountered an error while attempting to update latest block:
Error: ETIMEDOUT
at Timeout.<anonymous> (C:\Users\coolg\Desktop\hd_wallet\node_modules\request\request.js:848:19)
at listOnTimeout (internal/timers.js:549:17)
at processTimers (internal/timers.js:492:7)
at PollingBlockTracker._performSync (C:\Users\coolg\Desktop\hd_wallet\node_modules\eth-block-tracker\src\polling.js:51:24)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
Also a transaction for the above smart contract address 0xde674E126884c8F7Ddd94B5013065596b81fEd6d is created on ropsten network.
Edit 1:
I've replaced the provider link with wss://ropsten.infura.io/v3/${infuraKey}` and the 2nd issue gets resolved but now it shows another error
1_initial_migration.js
======================
Deploying 'Migrations'
----------------------
> transaction hash: 0xb72aef24e5fc16395f1dc221965c4e2036b4d72babbe829f244f958d302baee5
> Blocks: 7 Seconds: 228
> contract address: 0xb81478b107D5B08B0F9ce8d0E404701a3D2292a0
> block number: 12076445
> block timestamp: 1647090364
> account: 0xC10352218af6Ccbb574Fd0912adcc9Ac59C22950
> balance: 1.828763684345799891
> gas used: 175087 (0x2abef)
> gas price: 2.500000007 gwei
> value sent: 0 ETH
> total cost: 0.000437717501225609 ETH
Pausing for 2 confirmations...
-------------------------------
> confirmation number: 3 (block: 12076452)
⠦ Saving migration to chain.
Exiting: Review successful transactions manually by checking the transaction hashes above on Etherscan.
Error: Transaction was not mined within 750 seconds, please make sure your transaction was properly sent. Be aware that it might still be mined!
It says the transaction might still be mined, so how will i know when my transaction gets mined? Also in the meantime can i call the fuctions/events of my smart contract that is deployed on the ropsten_eth https://ropsten.etherscan.io/address/0xb81478b107d5b08b0f9ce8d0e404701a3d2292a0
The problem here by mistake may be the address you are trying to reach. I searched for what the problem might be and found two threads where people have already described the problem and sort of found a solution. Most likely one of these options should help to solve the problem.
The first solution is here. The idea is to replace https with wss. There should be something like this:
testnet: {
provider: () => new HDWalletProvider(mnemonic, `wss://ropsten.infura.io/v3/${infuraKey}`),
...
}
Then I searched some more and found something like this. The author of the post says that the problem could be due to DNS or slow internet and suggests adding two parameters to the config:
testnet: {
...,
networkCheckTimeout: 10000,
timeoutBlocks: 200
}

Why do I get `sealing paused while waiting for transactions` error when mining in Ethereum private network?

I launched a private network by using geth --datadir data/node1 --http --dev --http.corsdomain "*" --http.api web3,eth,debug,personal,net,miner --allow-insecure-unlock --mine command.
I am able to attach to it geth attach http://localhost:8545
but the balance of the default account is only 1.15 ether:
eth.getBalance(eth.accounts[0]) 1.15792089237316195423570985008687907853269984665640564039457582226449518702905e+77
I'd like to give it more ethers so I run:
miner.start()
null
And I can see there is a warn in the node log:
INFO [11-28|20:29:38.512] Transaction pool price threshold updated price=1
INFO [11-28|20:29:38.512] Commit new mining work number=4 sealhash=73b6e7..5d8b72 uncles=0 txs=0 gas=0 fees=0 elapsed="174.436µs"
WARN [11-28|20:29:38.512] Block sealing failed err="sealing paused while waiting for transactions"
I wonder what the issue could be?
Perhaps you have not previously given permission for the miner to sign the genesis block.
POA uses the Clique API to manage the seal list.
> clique.proposals
{}
> clique.propose("0xc077f8420d5b6c125897d9c5e21293ff6f77855c", true)
true
> clique.proposals
{
0xc077f8420d5b6c125897d9c5e21293ff6f77855c: true
}
> clique.getSnapshot()
{
hash: "0xfbfe67cd638d21f528036130cc703be8f8fdccb934d871f3f8c2eccda1ed4bf5",
number: 11,
recents: {
10: "0xc077f8420d5b6c125897d9c5e21293ff6f77855c",
11: "0x726794b16f6c5b0be0b78d7713a876ed3da8be1a"
},
signers: {
0x726794b16f6c5b0be0b78d7713a876ed3da8be1a: {},
0xc077f8420d5b6c125897d9c5e21293ff6f77855c: {}
},
tally: {},
votes: []
}`enter code here`
enter code here
You can see more details in this manual: https://yenhuang.gitbooks.io/blockchain/content/interact-with-private-chain-on-android/build-the-private-chain.html
You can also top up your balance using:
eth.sendTransaction({from:eth.coinbase, to:eth.accounts[1], value: web3.toWei(0.05, "ether")})
but the balance of the default account is only 1.15 ether:
eth.getBalance(eth.accounts[0])
1.15792089237316195423570985008687907853269984665640564039457582226449518702905e+77
I didn’t pay attention to it right away. But this is not 1.15 ETH, this is a huge number of ETH that will not end and you can transfer it from coinbase to other created accounts on your private network in dev mode.

Error: Deployment Failed while using Matic Test Network

I am getting started with Application development on Matic. And I am following the instruction as provided on the docs https://docs.matic.network/docs/develop/getting-started
But I faced problem while using truffle. After I run the command
truffle migrate --network matic
The error as follow:
Compiling your contracts...
===========================
> Everything is up to date, there is nothing to compile.
Starting migrations...
======================
> Network name: 'matic'
> Network id: 80001
> Block gas limit: 20000000 (0x1312d00)
1_initial_migration.js
======================
Deploying 'Migrations'
----------------------
Error: *** Deployment Failed ***
"Migrations" -- insufficient funds for gas * price + value.
at /usr/local/lib/node_modules/truffle/build/webpack:/packages/deployer/src/deployment.js:365:1
at process._tickCallback (internal/process/next_tick.js:68:7)
Truffle v5.1.55 (core: 5.1.55)
Node v10.19.0
The configuration file of truffle as follow:
const HDWalletProvider = require('truffle-hdwallet-provider');
const fs = require('fs');
const mnemonic = fs.readFileSync(".secret").toString().trim();
module.exports = {
networks: {
development: {
host: "127.0.0.1", // Localhost (default: none)
port: 8545, // Standard Ethereum port (default: none)
network_id: "*", // Any network (default: none)
},
matic: {
provider: () => new HDWalletProvider(mnemonic, `https://rpc-mumbai.matic.today`),
network_id: 80001,
confirmations: 2,
timeoutBlocks: 200,
skipDryRun: true
},
},
// Set default mocha options here, use special reporters etc.
mocha: {
// timeout: 100000
},
// Configure your compilers
compilers: {
solc: {
}
}
}
It worked fine for the develop network using
truffle develop
Can someone tell me how to overcome error while using Matic Test Network?
Make sure you have enough MATIC for the transaction, you can get some from here and transfer them to the account[0]. I had issues deploying with truffle as all my tokens were at account[1] rather than account[0]
in my case it was ETH, ensuring i had tokens in the first account did the trick

Truffle error: Error: VM Exception while processing transaction: revert

I am using truffle:
truffle(development)> var hw
undefined
truffle(development)> HelloWorld.deployed().then(function(deployed){hw=deployed;});
undefined
truffle(development)> hw.SayHello.call()
i am getting below error in Truffle
***Error: VM Exception while processing transaction: revert
at Object.InvalidResponse (C:\Users\dell\AppData\Roaming\npm\node_modules\truffle\build\cli.bundled.js:41484:16)
at C:\Users\dell\AppData\Roaming\npm\node_modules\truffle\build\cli.bundled.js:328866:36
at C:\Users\dell\AppData\Roaming\npm\node_modules\truffle\build\cli.bundled.js:324536:9
at XMLHttpRequest.request.onreadystatechange (C:\Users\dell\AppData\Roaming\npm\node_modules\truffle\build\cli.bundled.js:327565:7)
at XMLHttpRequestEventTarget.dispatchEvent (C:\Users\dell\AppData\Roaming\npm\node_modules\truffle\build\cli.bundled.js:176407:18)
at XMLHttpRequest._setReadyState (C:\Users\dell\AppData\Roaming\npm\node_modules\truffle\build\cli.bundled.js:176697:12)
at XMLHttpRequest._onHttpResponseEnd (C:\Users\dell\AppData\Roaming\npm\node_modules\truffle\build\cli.bundled.js:176852:12)
at IncomingMessage.<anonymous> (C:\Users\dell\AppData\Roaming\npm\node_modules\truffle\build\cli.bundled.js:176812:24)
at emitNone (events.js:111:20)
at IncomingMessage.emit (events.js:208:7) ***
1) My HelloWorld.sol
`
pragma solidity ^0.4.8;
contract HelloWorld {
function SayHello() public returns (string) {
return ("SomeHello");
}
}
2) My 2_deploy_contracts.js
var ConvertLib = artifacts.require("./ConvertLib.sol");
var MetaCoin = artifacts.require("./MetaCoin.sol");
var HelloWorld = artifacts.require("./HelloWorld.sol");
var second = artifacts.require("./second.sol");
module.exports = function(deployer) {
deployer.deploy(ConvertLib);
deployer.link(ConvertLib, MetaCoin);
deployer.deploy(MetaCoin);
deployer.deploy(HelloWorld);
deployer.deploy(second);
};
3) My truffle.js
module.exports = {
networks: {
development: {
host: "localhost",
port: 8545,
network_id: "*" // Match any network id
}
}
};
Please let me know how can I fix above error ?
`
I just ran your example and it worked fine. The only change I made was I removed the other smart contracts from 2_deploy_contracts that aren't used. Make sure you are running the compile and migrate commands and testrpc is running before starting the truffle console. Also, just in case you're running on Windows, rename truffle.js to truffle-config.js
$ truffle compile
Compiling .\contracts\HelloWorld.sol...
Writing artifacts to .\build\contracts
$ truffle migrate
Using network 'development'.
Running migration: 2_deploy_contracts.js
Deploying HelloWorld...
... 0xef7e895758805a3c3c9aaed7dc7c97fe7b2278b0c0d6ee8105192183a86188c9
HelloWorld: 0x54329ff919efda7920408084590d7480a6c88243
Saving successful migration to network...
... 0x0954625bf66275469c9475ca21f5db20bc4667efb716c5e19bfd98a9553f4a83
Saving artifacts...
$ truffle console
truffle(development)> var hw
undefined
truffle(development)> HelloWorld.deployed().then(function(deployed){hw=deployed;});
undefined
truffle(development)> hw.SayHello.call()
'SomeHello'
truffle(development)>
2_deploy_contracts.js
var HelloWorld = artifacts.require("./HelloWorld.sol");
module.exports = function(deployer) { deployer.deploy(HelloWorld); };