@dan-i
In simpler words I want to explain my Problem.
How do i get Current message ; Hello again on my terminal , and as you would be knowing i have sudo npm -g [email protected] installed on my Mac ??
Thanks and Regards
Suveett Kalra
@dan-i
In simpler words I want to explain my Problem.
How do i get Current message ; Hello again on my terminal , and as you would be knowing i have sudo npm -g [email protected] installed on my Mac ??
Thanks and Regards
Suveett Kalra
I am using a Mac
when I use the following code in 2_Helloworld_deploy.js,
const Helloworld = artifacts.require("Helloworld");
module.exports = function (deployer, network, accounts) {
deployer.deploy(Helloworld).then(function(instance){
instance.setMessage("Hello again !", {value : 1000000, from : accounts[0]}).then(function(){
instance.getMessage().then(function(message){
console.log("Current Message :" + message);
});
});
});
};
I get the following error on the Terminal
transaction hash: 0x9784d34942c6c5fabde8deb8247411c70918dd43102daea077c7feae60a5763d
Blocks: 0 Seconds: 0
contract address: 0xfd26e43567D35a13C16681782a1a7af5F39B90f8
block number: 4
block timestamp: 1608055948
account: 0x687f17fe288c4AD8Fa4A918239DaA75b79062B75
balance: 99.98284558
gas used: 297116 (0x4889c)
gas price: 20 gwei
value sent: 0 ETH
total cost: 0.00594232 ETH
⠋ Saving migration to chain.{ Error: Provided address “g” is invalid, the capitalization checksum test failed, or its an indrect IBAN address which can’t be converted.
at /Users/aadyakalra/Documents/Ethereum-course-advanced/Helloworld/migrations/2_Helloworld_deploy.js:30:14
at /Users/aadyakalra/Documents/Ethereum-course-advanced/Helloworld/node_modules/truffle/build/webpack:/packages/deployer/src/deferredchain.js:20:1
at process._tickCallback (internal/process/next_tick.js:68:7)
hijackedStack:
‘Error: Provided address “g” is invalid, the capitalization checksum test failed, or its an indrect IBAN address which can’t be converted.\n at inputAddressFormatter (/Users/aadyakalra/Documents/Ethereum-course-advanced/Helloworld/node_modules/truffle/build/webpack:/node_modules/web3-core-helpers/src/formatters.js:475:1)\n at Method.inputTransactionFormatter (/Users/aadyakalra/Documents/Ethereum-course-advanced/Helloworld/node_modules/truffle/build/webpack:/node_modules/web3-core-helpers/src/formatters.js:211:1)\n at /Users/aadyakalra/Documents/Ethereum-course-advanced/Helloworld/node_modules/truffle/build/webpack:/node_modules/web3-eth/node_modules/web3-core-method/src/index.js:150:1\n at Array.map ()\n at Method.formatInput (/Users/aadyakalra/Documents/Ethereum-course-advanced/Helloworld/node_modules/truffle/build/webpack:/node_modules/web3-eth/node_modules/web3-core-method/src/index.js:148:1)\n at Method.toPayload (/Users/aadyakalra/Documents/Ethereum-course-advanced/Helloworld/node_modules/truffle/build/webpack:/node_modules/web3-eth/node_modules/web3-core-method/src/index.js:183:1)\n at Eth.send [as sendTransaction] (/Users/aadyakalra/Documents/Ethereum-course-advanced/Helloworld/node_modules/truffle/build/webpack:/node_modules/web3-eth/node_modules/web3-core-method/src/index.js:617:1)\n at Object.sendTransaction (/Users/aadyakalra/Documents/Ethereum-course-advanced/Helloworld/node_modules/truffle/build/webpack:/packages/contract/lib/execute.js:529:1)\n at execute.prepareCall.then (/Users/aadyakalra/Documents/Ethereum-course-advanced/Helloworld/node_modules/truffle/build/webpack:/packages/contract/lib/execute.js:203:1)\n at process._tickCallback (internal/process/next_tick.js:68:7)’ }
{ Error: Provided address “g” is invalid, the capitalization checksum test failed, or its an indrect IBAN address which can’t be converted.
at /Users/aadyakalra/Documents/Ethereum-course-advanced/Helloworld/migrations/2_Helloworld_deploy.js:30:14
at /Users/aadyakalra/Documents/Ethereum-course-advanced/Helloworld/node_modules/truffle/build/webpack:/packages/deployer/src/deferredchain.js:20:1
at process._tickCallback (internal/process/next_tick.js:68:7)
hijackedStack:
‘Error: Provided address “g” is invalid, the capitalization checksum test failed, or its an indrect IBAN address which can’t be converted.\n at inputAddressFormatter (/Users/aadyakalra/Documents/Ethereum-course-advanced/Helloworld/node_modules/truffle/build/webpack:/node_modules/web3-core-helpers/src/formatters.js:475:1)\n at Method.inputTransactionFormatter (/Users/aadyakalra/Documents/Ethereum-course-advanced/Helloworld/node_modules/truffle/build/webpack:/node_modules/web3-core-helpers/src/formatters.js:211:1)\n at /Users/aadyakalra/Documents/Ethereum-course-advanced/Helloworld/node_modules/truffle/build/webpack:/node_modules/web3-eth/node_modules/web3-core-method/src/index.js:150:1\n at Array.map ()\n at Method.formatInput (/Users/aadyakalra/Documents/Ethereum-course-advanced/Helloworld/node_modules/truffle/build/webpack:/node_modules/web3-eth/node_modules/web3-core-method/src/index.js:148:1)\n at Method.toPayload (/Users/aadyakalra/Documents/Ethereum-course-advanced/Helloworld/node_modules/truffle/build/webpack:/node_modules/web3-eth/node_modules/web3-core-method/src/index.js:183:1)\n at Eth.send [as sendTransaction] (/Users/aadyakalra/Documents/Ethereum-course-advanced/Helloworld/node_modules/truffle/build/webpack:/node_modules/web3-eth/node_modules/web3-core-method/src/index.js:617:1)\n at Object.sendTransaction (/Users/aadyakalra/Documents/Ethereum-course-advanced/Helloworld/node_modules/truffle/build/webpack:/packages/contract/lib/execute.js:529:1)\n at execute.prepareCall.then (/Users/aadyakalra/Documents/Ethereum-course-advanced/Helloworld/node_modules/truffle/build/webpack:/packages/contract/lib/execute.js:203:1)\n at process._tickCallback (internal/process/next_tick.js:68:7)’ }
And when i use the Following code
const Helloworld = artifacts.require("Helloworld");
module.exports = function(deployer,accounts) {
deployer.deploy(Helloworld).then(function(instance){
instance.setMessage("Hello Again!", {value: 1000000, from: accounts[0]}).then(function(){
console.log("Set message");
});
instance.getMessage().then(function(message){
console.log("Current message: " + message);
});
});
};
transaction hash: 0xbf2f8cce586204c5ee14cb23d78ea3025cff38c76abda228da5616c0e3a96c08
Blocks: 0 Seconds: 0
contract address: 0x8D6a4fB17B5D5813360eDFe4529D4F742F038050
block number: 5
block timestamp: 1608056385
account: 0x687f17fe288c4AD8Fa4A918239DaA75b79062B75
balance: 99.97690326
gas used: 297116 (0x4889c)
gas price: 20 gwei
value sent: 0 ETH
total cost: 0.00594232 ETH
⠋ Saving migration to chain.{ Error: Provided address “g” is invalid, the capitalization checksum test failed, or its an indrect IBAN address which can’t be converted.
at /Users/aadyakalra/Documents/Ethereum-course-advanced/Helloworld/migrations/2_Helloworld_deploy.js:30:14
at /Users/aadyakalra/Documents/Ethereum-course-advanced/Helloworld/node_modules/truffle/build/webpack:/packages/deployer/src/deferredchain.js:20:1
at process._tickCallback (internal/process/next_tick.js:68:7)
hijackedStack:
‘Error: Provided address “g” is invalid, the capitalization checksum test failed, or its an indrect IBAN address which can’t be converted.\n at inputAddressFormatter (/Users/aadyakalra/Documents/Ethereum-course-advanced/Helloworld/node_modules/truffle/build/webpack:/node_modules/web3-core-helpers/src/formatters.js:475:1)\n at Method.inputTransactionFormatter (/Users/aadyakalra/Documents/Ethereum-course-advanced/Helloworld/node_modules/truffle/build/webpack:/node_modules/web3-core-helpers/src/formatters.js:211:1)\n at /Users/aadyakalra/Documents/Ethereum-course-advanced/Helloworld/node_modules/truffle/build/webpack:/node_modules/web3-eth/node_modules/web3-core-method/src/index.js:150:1\n at Array.map ()\n at Method.formatInput (/Users/aadyakalra/Documents/Ethereum-course-advanced/Helloworld/node_modules/truffle/build/webpack:/node_modules/web3-eth/node_modules/web3-core-method/src/index.js:148:1)\n at Method.toPayload (/Users/aadyakalra/Documents/Ethereum-course-advanced/Helloworld/node_modules/truffle/build/webpack:/node_modules/web3-eth/node_modules/web3-core-method/src/index.js:183:1)\n at Eth.send [as sendTransaction] (/Users/aadyakalra/Documents/Ethereum-course-advanced/Helloworld/node_modules/truffle/build/webpack:/node_modules/web3-eth/node_modules/web3-core-method/src/index.js:617:1)\n at Object.sendTransaction (/Users/aadyakalra/Documents/Ethereum-course-advanced/Helloworld/node_modules/truffle/build/webpack:/packages/contract/lib/execute.js:529:1)\n at execute.prepareCall.then (/Users/aadyakalra/Documents/Ethereum-course-advanced/Helloworld/node_modules/truffle/build/webpack:/packages/contract/lib/execute.js:203:1)\n at process._tickCallback (internal/process/next_tick.js:68:7)’ }
{ Error: Provided address “g” is invalid, the capitalization checksum test failed, or its an indrect IBAN address which can’t be converted.
at /Users/aadyakalra/Documents/Ethereum-course-advanced/Helloworld/migrations/2_Helloworld_deploy.js:30:14
at /Users/aadyakalra/Documents/Ethereum-course-advanced/Helloworld/node_modules/truffle/build/webpack:/packages/deployer/src/deferredchain.js:20:1
at process._tickCallback (internal/process/next_tick.js:68:7)
hijackedStack:
‘Error: Provided address “g” is invalid, the capitalization checksum test failed, or its an indrect IBAN address which can’t be converted.\n at inputAddressFormatter (/Users/aadyakalra/Documents/Ethereum-course-advanced/Helloworld/node_modules/truffle/build/webpack:/node_modules/web3-core-helpers/src/formatters.js:475:1)\n at Method.inputTransactionFormatter (/Users/aadyakalra/Documents/Ethereum-course-advanced/Helloworld/node_modules/truffle/build/webpack:/node_modules/web3-core-helpers/src/formatters.js:211:1)\n at /Users/aadyakalra/Documents/Ethereum-course-advanced/Helloworld/node_modules/truffle/build/webpack:/node_modules/web3-eth/node_modules/web3-core-method/src/index.js:150:1\n at Array.map ()\n at Method.formatInput (/Users/aadyakalra/Documents/Ethereum-course-advanced/Helloworld/node_modules/truffle/build/webpack:/node_modules/web3-eth/node_modules/web3-core-method/src/index.js:148:1)\n at Method.toPayload (/Users/aadyakalra/Documents/Ethereum-course-advanced/Helloworld/node_modules/truffle/build/webpack:/node_modules/web3-eth/node_modules/web3-core-method/src/index.js:183:1)\n at Eth.send [as sendTransaction] (/Users/aadyakalra/Documents/Ethereum-course-advanced/Helloworld/node_modules/truffle/build/webpack:/node_modules/web3-eth/node_modules/web3-core-method/src/index.js:617:1)\n at Object.sendTransaction (/Users/aadyakalra/Documents/Ethereum-course-advanced/Helloworld/node_modules/truffle/build/webpack:/packages/contract/lib/execute.js:529:1)\n at execute.prepareCall.then (/Users/aadyakalra/Documents/Ethereum-course-advanced/Helloworld/node_modules/truffle/build/webpack:/packages/contract/lib/execute.js:203:1)\n at process._tickCallback (internal/process/next_tick.js:68:7)’ }
Please help me, as I unable to carry on with the course.
**The command on the terminal i gave is **
./node_modules/.bin/truffle migrate
Thanks and Regards
Suveett Kalra
try the following
Create an empty folder named 'Helloworld" in your desktop inside the documents folder ( similar to what @filip explained ) and now navigate into the folder using Terminal.
in the terminal type as below
npm init
it will ask you some questions, just press enter to all of them.
Now check in the Helloworld folder, it would have created a package.json folder in it.
Now type in the Terminal :
npm i truffle
Now type again in the terminal :
./node_modules/.bin/truffle init
Now you will have the following truffle folders in the Helloworld folder
contracts/migrations/test
Now follow the videos of Filip and Create your Helloworld.sol file and the 2_Helloworld_deploy.js file in your atom text editor
Now type in the terminal :
./node_modules/.bin/truffle compile
and you are good to go… Hopefully you will not encounter any issues and it solves your problems.
Can you console.log accounts[0]?
Post a screenshot of the result
Can you tell me where i am going wrong because i am getting a VM error : revert
My code is as Below
Helloworld.sol
pragma solidity 0.5.12;
contract Helloworld {
string message = "Hello World !! ";
function getMessage() public view returns(string memory) {
return message;
}
function setMessage(string memory newMessage) public payable {
require(msg.value >= 100 wei);
message = newMessage;
}
}
and my code in 2_Helloworld_deploy.js is as below
const Helloworld = artifacts.require("Helloworld");
module.exports = function(deployer,network,accounts) {
deployer.deploy(Helloworld).then(function(instance){
instance.setMessage("Hello again !", { value : 1000000, from : accounts[0]}).then(function(){
console.log("Success");
}).catch(function(err){
console.log("error : " + err);
});
}).catch(function(err){
console.log("Deploy failed : " + error);
});
};
I am getting a VM error : revert
In my opinion, it should run fine because in Helloworld.sol file the i have the following condition
require(msg.value >= 100 wei);
and in my 2_Helloworld_deploy.js file the setMessage function provides 1000000 wei
instance.setMessage("Hello again !", { value : 1000000, from : accounts[0]}).then(function(){
Thanks and awaiting your answer because I am unable to understand whats going on here.
Regards
Suveett kalra
su.kal crypto
That does not seem to be a truffle project.
I suggest you to go through the Academy lessons and follow the steps, Filip explains them perfectly:
https://academy.ivanontech.com/products/ethereum-smart-contract-programming-201
Send the error message, just ‘revert’ is not enough for me to understand the issue.
A screenshot would be perfect.
Regards
Hi @dan-i congrats on BTC touching 23k
So you can see the entire Terminal code here:
**Initially I ran the migrate – reset and it ran successfully as below , but later on running the console and running instance.setMessage(), it shows the VM error : revert… Have a look at the code below **
transaction hash: 0xdcbff4db1b70d6c9a2a2378f78ffc284243809ecba2155351c069425fb65a3bc
Blocks: 0 Seconds: 0
contract address: 0x7cCfDbF540ab6C8480651E72AdAb36F6B3D113FD
block number: 26
block timestamp: 1608216380
account: 0x687f17fe288c4AD8Fa4A918239DaA75b79062B75
balance: 99.943209099996
gas used: 221491 (0x36133)
gas price: 20 gwei
value sent: 0 ETH
total cost: 0.00442982 ETH
Saving migration to chain.
Saving artifacts
Total cost: 0.00442982 ETH
transaction hash: 0xc73bbe06bf55151af5cfbef4518b2037c8d18359d92aa8edbd6a88404f3d7eb0
Blocks: 0 Seconds: 0
contract address: 0x1B5AB7D95f9A4fBaEEC6d0A95C92b4F923C92476
block number: 28
block timestamp: 1608216380
account: 0x687f17fe288c4AD8Fa4A918239DaA75b79062B75
balance: 99.936347939996
gas used: 301060 (0x49804)
gas price: 20 gwei
value sent: 0 ETH
total cost: 0.0060212 ETH
⠋ Saving migration to chain.Current Message :Hello again !
⠙ Saving migration to chain.Success
Saving migration to chain.
Saving artifacts
Total cost: 0.0060212 ETH
Total deployments: 2
Final cost: 0.01045102 ETH
aadyakalra@Aadyas-MacBook-Air Helloworld % ./node_modules/.bin/truffle console
truffle(ganache)> instance = await Helloworld.deployed()
undefined
truffle(ganache)> instance.getMessage()
‘Hello again !’
truffle(ganache)> instance.setMessage(“Hi Ivan , congrats on BTC touching 23k USD today !!”)
Thrown:
{ Error: Returned error: VM Exception while processing transaction: revert
at evalmachine.:0:10
at sigintHandlersWrap (vm.js:288:15)
at Script.runInContext (vm.js:130:14)
at runScript (/Users/aadyakalra/Documents/Ethereum-course-advanced/Helloworld/node_modules/truffle/build/webpack:/packages/core/lib/console.js:251:1)
at Console.interpret (/Users/aadyakalra/Documents/Ethereum-course-advanced/Helloworld/node_modules/truffle/build/webpack:/packages/core/lib/console.js:266:1)
at bound (domain.js:402:14)
at REPLServer.runBound [as eval] (domain.js:415:12)
at REPLServer.onLine (repl.js:642:10)
at REPLServer.emit (events.js:198:13)
at REPLServer.EventEmitter.emit (domain.js:448:20)
at REPLServer.Interface._onLine (readline.js:308:10)
at REPLServer.Interface._line (readline.js:656:8)
at REPLServer.Interface._ttyWrite (readline.js:937:14)
at REPLServer.self._ttyWrite (repl.js:715:7)
at ReadStream.onkeypress (readline.js:184:10)
at ReadStream.emit (events.js:198:13)
at ReadStream.EventEmitter.emit (domain.js:448:20)
at emitKeys (internal/readline.js:424:14)
at emitKeys.next ()
at ReadStream.onData (readline.js:1073:36)
at ReadStream.emit (events.js:198:13)
at ReadStream.EventEmitter.emit (domain.js:448:20)
at addChunk (_stream_readable.js:288:12)
at readableAddChunk (_stream_readable.js:269:11)
at ReadStream.Readable.push (_stream_readable.js:224:10)
at TTY.onStreamRead [as onread] (internal/stream_base_commons.js:94:17)
hijackedStack:
‘Error: Returned error: VM Exception while processing transaction: revert\n at Object.ErrorResponse (/Users/aadyakalra/Documents/Ethereum-course-advanced/Helloworld/node_modules/truffle/build/webpack:/node_modules/web3-core-helpers/src/errors.js:29:1)\n at /Users/aadyakalra/Documents/Ethereum-course-advanced/Helloworld/node_modules/truffle/build/webpack:/node_modules/web3/node_modules/web3-core-requestmanager/src/index.js:170:1\n at /Users/aadyakalra/Documents/Ethereum-course-advanced/Helloworld/node_modules/truffle/build/webpack:/packages/provider/wrapper.js:107:1\n at XMLHttpRequest.request.onreadystatechange (/Users/aadyakalra/Documents/Ethereum-course-advanced/Helloworld/node_modules/truffle/build/webpack:/node_modules/web3/node_modules/web3-providers-http/src/index.js:111:1)\n at XMLHttpRequestEventTarget.dispatchEvent (/Users/aadyakalra/Documents/Ethereum-course-advanced/Helloworld/node_modules/truffle/build/webpack:/node_modules/xhr2-cookies/dist/xml-http-request-event-target.js:34:1)\n at XMLHttpRequest._setReadyState (/Users/aadyakalra/Documents/Ethereum-course-advanced/Helloworld/node_modules/truffle/build/webpack:/node_modules/xhr2-cookies/dist/xml-http-request.js:208:1)\n at XMLHttpRequest._onHttpResponseEnd (/Users/aadyakalra/Documents/Ethereum-course-advanced/Helloworld/node_modules/truffle/build/webpack:/node_modules/xhr2-cookies/dist/xml-http-request.js:318:1)\n at IncomingMessage. (/Users/aadyakalra/Documents/Ethereum-course-advanced/Helloworld/node_modules/truffle/build/webpack:/node_modules/xhr2-cookies/dist/xml-http-request.js:289:47)\n at IncomingMessage.emit (events.js:203:15)\n at IncomingMessage.EventEmitter.emit (domain.js:466:23)\n at endReadableNT (_stream_readable.js:1145:12)\n at process._tickCallback (internal/process/next_tick.js:63:19)’ }
truffle(ganache)>
So you can see in the previous file i sent that inspite of setMessage payable function having a “require of only 100 wei”, and in my 2_Helloworld_deploy.js file the value is {value : 1000000 wei}, its still showing VM error: revert
Kindly please help
regards
Su.kal crypto
The migration is correct and indeed completes until the end.
The error is in the command you are giving in the truffle console.
Here:
truffle(ganache)> instance.getMessage()
‘Hello again !’
truffle(ganache)> instance.setMessage(“Hi Ivan , congrats on BTC touching 23k USD today !!”)
Thrown:
{ Error: Returned error: VM Exception while processing transaction: revert
In your contract you’ve declared the function setMessage()
as payable and you require that msg.value > 100 wei, but you are not sending eth.
Fix this one and follow the same you did in the migration:
instance.setMessage(“Hi Ivan , congrats on BTC touching 23k USD today !!”)
@dan-i But how to send the ETH in the contract ??
This is my below code in the 2_Helloworld_deploy.js
const Helloworld = artifacts.require("Helloworld");
module.exports = function(deployer,network,accounts) {
deployer.deploy(Helloworld).then(function(instance){
instance.setMessage("Hello again !", { value : 1000000, from : accounts[0]}).then(function(){
console.log("Success");
}).catch(function(err){
console.log("error : " + err);
});
instance.getMessage().then(function(message){
console.log("Current Message :" + message);
});
}).catch(function(err){
console.log("Deploy failed : " + error);
});
};
Please tell me where I am going wrong ?
thanks and regards
su.kal Crypto
You need to use the same command that you already use in your migration.
instance.setMessage(“Hello again !”, { value : 1000000, from : accounts[0]})
Hi @filip
in this course, can I use Ganache 2.5.4, because I got error when I start the Ganache 2.1.1
-Paul Kwok
You can surely use an updated version of ganache, you should be able to proceed.
Keep me posted.
@filip first of all thank you for including us in space! Big shout out!
And like everyone here, I have truble when trying to initialize truffle:
PS D:> cd Helloworld/
PS D:\Helloworld> truffle init
truffle : File C:\Users\MAŠA I SOFIJA\AppData\Roaming\npm\truffle.ps1 cannot be loaded because running scripts is disab
led on this system. For more information, see about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170
.
At line:1 char:1
+ CategoryInfo : SecurityError: (:) [], PSSecurityException
+ FullyQualifiedErrorId : UnauthorizedAccess
PS D:\Helloworld>
What do you recommend me to do?
I’m running into an issue where my console.log command isn’t printing anything onto the screen. Within powershell I can run getMessage() and see that the message has been updated by the deploy.js file. This is my code
const HelloWorld = artifacts.require("HelloWorld");
module.exports = function (deployer) {
deployer.deploy(HelloWorld).then(function(instance){
instance.setMessage("Hello Again!").then(function(){
instance.getMessage().then(function(message){
console.log("Current message: " + message);
});
});
});
};
Open a new powershell window as administrator and run this command
Set-ExecutionPolicy -ExecutionPolicy Bypass
Now run the init again
I have a question when I apply the following function. the account balance of the player address is not increase by the msg.value? I can see the log shows the value I define in msg.value.
// withdraw fund from contract for player
function withdrawFromPlayer() public payable {
require(playerBalance[msg.sender] >= msg.value);
require(msg.value > 0);
uint playerbalance;
uint toTransfer = msg.value;
playerBalance[msg.sender] -= toTransfer;
playerbalance = playerBalance[msg.sender];
msg.sender.transfer(toTransfer);
emit WithdrawFromPlayer(msg.sender, toTransfer, playerbalance);
}
for example, I deposite 3 Ether to playerBalance[msg.sender], then I withdraw 1 Ether from playerBalance[msg.sender], the balance of playerBalance[msg.sender] is 2. but I don’t see +1 ether from player’s account.