Questions tagged [truffle-console]
The truffle-console tag has no usage guidance.
53
questions
0
votes
1
answer
42
views
Why am I getting `undefined` when trying to access array elements in Truffle Console?
I am getting an array from my contract, which seems to have the correct number of elements. However, when trying to access the first element using index notation, I am getting undefined:
myArray = ...
0
votes
1
answer
437
views
Truffle Test Console Logging
I'm having some trouble with Truffle logging configuration. During tests, each submitted transaction and its hash is logged on the console and this one becomes full of useless messages that disturb ...
0
votes
1
answer
11
views
Truffle Console: If-condition not working
In the following code my false condition doesn't work, I have made sample program:
const path = require("path");
const fs = require("fs");
module.exports = async function(callback) ...
0
votes
1
answer
53
views
Truffle console: Can't Retrieve Solidity send(..) and transfer(..) from SC code
I have written a program for Truffle console. My code accesses the string and should return statements related to Solidity send and transfer. When I am testing each line of Solidity SC as shown below,...
0
votes
1
answer
92
views
contract.getPastEvents() take too much time
I have configured a private blockchain with some solidity smartcontract inside a docker container on my AWS VPS.
When I connect to the blockchain with truffle console --network besu and test the ...
0
votes
1
answer
1k
views
How to reference One Contract Into Another Contract In Solidity
I have 3 contracts that I am trying to deploy.2 are dependent on the third one, but for some reason, I am unable to call function from the other contract. Below is my code.
ERC20 Token
// SPDX-License-...
0
votes
1
answer
726
views
Revert Error When Using Truffle Console
I'm working on a smart contract and when I try to call my contract methods from the truffle console, I am getting a revert error. I can't figure out why this is happening. The contract is deployed ...
0
votes
1
answer
258
views
How to send more than 10^15 of an ERC20 token using the truffle console?
I am trying to test my contract but everytime I try to send more than 10^15 I get an overflow error while I know my wallet can send more than that. Any solutions?
pragma solidity 0.8.0;
import "@...
0
votes
2
answers
183
views
Truffle script: how to run multiple assertions without stopping the program?
I am trying to run multiple assertion using a single script. My script stops after the first assertion: My output is:
t$ truffle exec ts4_for_forum.js
Using network 'development'.
acc2 balance ...
1
vote
1
answer
311
views
truffle script:Cant retrieve the transaction receipt, dont know how to get transaction sender and receiver
I am executing the following script, I don't know how to retrieve the sender and receiver from the transaction receipt. I am trying to retrieve the transaction receipt but it does not work.
// ...
0
votes
1
answer
167
views
Truffle script: Not showing the current balance of the Smart contract (SC) after Ether transfer from account[2] immediately
I have a Smart contract (SC1):
pragma solidity ^0.5.8;
contract MySC1 {
address owner;
constructor() public {
owner = msg.sender;
}
function sendTo(address payable receiver, ...
0
votes
1
answer
48
views
Problem with executing Truffle script:'Exchange' i.e. the smart contract (SC) has not been deployed to detected network
I am following the tutorial provided at:
Example of Truffle script
But I have added the ganache, compilation and migrate. In migration I am getting the following error:
$ truffle exec ts2.js
Using ...
1
vote
0
answers
18
views
Truffle Console: How to specify SCs entire balance?
I am testing following contract on Truffle console:
MyContract:
contract MyContract {
address owner;
constructor() public {
owner = msg.sender;
}
function sendTo(address ...
3
votes
1
answer
137
views
Executing reentrancy on Truffle Console: attacker not stealing 5 ether , why only 2 reentrant calls?
I am doing the example provided at:
JustDev
I have parameterized the withdraw method.
Victim SC is:
pragma solidity ^0.5.8;
contract Victim{
address owner;
constructor() public{
owner = ...
1
vote
0
answers
38
views
Truffle Console Script giving Error: Cannot find module
I am trying to run the following script:
const messageBuild = require('./build/contracts/MyContract.json')
const MyContract = require('~/Truffle_programs/script_transfer_Eth_thr_Truffle/contracts/...
1
vote
0
answers
343
views
Executing the Truffle console script:Error: ENOENT: no such file or directory,
I am trying to execute the following script:
module.exports = (callback)=> {
Message.setProvider(web3.currentProvider);
const MyContract = require("~/Truffle programs/...
1
vote
1
answer
785
views
Truffle Console: Sending 3 or '3000000000000000' through Solidity function but receiver gets '0.000000000000000003' Ether
I am trying to send Ether in Ether units i.e. 3 ethers by two different techniques using truffle console:
1)truffle(development)> C1.sendTo(C2.address, 3)
and
2)truffle(development)> C1.sendTo(...
0
votes
0
answers
27
views
Error: Returned error: VM Exception while processing transaction [duplicate]
Gettting Error: Returned error: VM Exception while processing transaction
function getLatestPrice() public payable returns (int) {
(
uint80 roundID,
int price,
...
0
votes
2
answers
1k
views
Truffle Console: Sending Ether to a contract using fallback function
I have the following contract:
pragma solidity ^0.5.8;
contract Victim {
address owner;
constructor() public{
owner = msg.sender;
}
function deposit() payable public {}
}
If ...
1
vote
1
answer
514
views
How to calculate the gas cost of Solidity's 'transfer'?
I have read that the gas cost of transfer function is 2300Ether. I have got the following contract having a function, testFunc(…), only containing transfer method as shown below, because I want to ...
3
votes
1
answer
3k
views
Truffle Console: Estimate Gas Cost of a function
I checked the following link:
how to estimate gas cost?
My contract is:
pragma solidity ^0.5.1;
contract TransferGC{
uint public testVal = 97 ether;
function testFunc(address payable addr) ...
1
vote
1
answer
2k
views
Call an existing contract function from truffle console
Let's suppose an existing Ethereum deployed contract.
I know the deployment Address and i have the contract's source code.
What i want to do is to call a function on this deployed contract from ...
0
votes
2
answers
78
views
TruffleConsole: Not able to send Ether to an account using Smart Contract’s method
I have got a smart contract (SC) which is using transfer to send Ether. The transaction is happening but the balance of the account is not increasing.
pragma solidity ^0.5.1;
contract TransferTest{
...
1
vote
1
answer
1k
views
Truffle Console: How to print the value of a variable using get function
I want to printthe value of iVar:
pragma solidity ^0.5.1;
contract PRetVal {
uint8 iVar =0;
function testFunc() public returns (uint8) {
iVar = iVar + 10;
return iVar;...
0
votes
1
answer
310
views
selfdestruct: why am I able to execute the function containing selfdestruct(...) twice?
I have created the following contract with a destroy function invoking selfdestruct:
pragma solidity >=0.5.0 < 0.7.0;
contract Terminate{
function destroy() public {
selfdestruct(msg....
0
votes
1
answer
322
views
Truffle console: Accessing contract using an account other than owner
I have the following contract:
pragma solidity >= 0.5.0 < 0.7.0;
contract SimpleContract {
string public name;
address private owner;
constructor() public {
name = 'abs';
...
0
votes
1
answer
562
views
Truffle console: assert.equal, how to use exception for testing purposes?
I want to check the value returned by getName() function:
pragma solidity >= 0.5.0 < 0.7.0;
contract SimpleContract {
string public name;
constructor() public {
name = 'abs';
}
...
0
votes
0
answers
245
views
truffle console: Can't execute function i.e., TypeError: SimpleContract.at(...).getName is not a function
I am trying to familiarize with 'truffle console' by doing the tutorial at:
https://medium.com/oli-systems/test-driven-solidity-with-truffle-e4beaa2bd194
$truffle migrate
Compiling your contracts...
...
0
votes
1
answer
233
views
Questions about Truffle console and Truffle develop
When I inputted truffle console, it showed the error:
➜ via-issuer-master truffle console --network interaction
truffle(interaction)> var cash = aw
/usr/local/lib/node_modules/truffle/build/...
0
votes
1
answer
791
views
Sending ETH from contract to EOA
OK, I'm baffled guys. maybe it's the amount of gas the function is using up that is causing this not to work.
when I call the function:
I get the following in response but no movement of Eth from my ...
0
votes
0
answers
116
views
Truffle console: Exception instead of transaction
I am running the tutorial at:
Medium Just Dev
pragma solidity ^0.5.0;
import './Victim.sol';
contract Attacker{
Victim public v;
uint public count;
event LogFallback(uint c, uint ...
0
votes
0
answers
119
views
'VM Exception while processing transaction: revert\n' Error Processing transaction
I have read in various posts that this error occurs when there is a problem with executing function. So I'm asking about this error in regards to the code I have written.
Please see below:
contract ...
0
votes
1
answer
298
views
Truffle Console error : invalid number value. Value must be an integer, while executing commands from a tutorial
I am trying to execute commands from the following tutorial:
medium Dev Tutorial
I am getting an integer error while executing a command:
truffle(ganache)> balanceInEth = address => web3.utils....
1
vote
1
answer
3k
views
Error Truffle Console: web3.fromWei is not a function
I am executing commands from a tutorial at:
JustDev Tutorial on Medium
I am executing the command:
> truffle(ganache)> balanceInEth = address =>
> web3.fromWei(getBalance(address).toString(...
0
votes
0
answers
24
views
Garbage Value on Truffle console while executing the commands from a tutorial
I am following the tutorial at:
JustDev tutorial on medium
When I execute the command:
truffle(ganache)> Victim.deployed().then(contract => victim = contract)
I am getting a huge output which ...
0
votes
0
answers
75
views
VM Exception while processing transaction: revert at PromiEvent
I have a problem when calling smart contract function using truffle console. Previously I deployed smart contracts on ropsten, and there was no problem when calling smart contract function. Anyone ...
0
votes
1
answer
114
views
How to retrieve elements from a mapping to an array of structs
I have recently started playing around with SmartContracts and I have run into a problem which I can not find a solution to.
I have the following struct and mapping in my Smart Contract:
struct ...
0
votes
2
answers
488
views
app.vote(1, {from: web3.eth.accounts[0] }) not working
I am following a tutorial from Dapp University about building Election Smart Contract. When I run this command in the console:
app.vote(1, {from: web3.eth.accounts[0] })
I get the following error:
...
1
vote
4
answers
3k
views
Error: HelloWorld has not been deployed to detected network (network/artifact mismatch)
I'm following the steps in this link to create a truffle project.
I'm using ganache-cli as the ethereum client.
rajkumar@rajkumar: Ethereum$ mkdir helloworld
rajkumar@rajkumar: Ethereum$ cd ...
0
votes
1
answer
204
views
cannot "npm install -g truffle" in PowerShell - #ERROR (cannot find module 'original-require')
What's this error? How can I resolve
0
votes
0
answers
412
views
How to use the address.transfer(amount)?
Using this smart contract, I want to transfer from one account to another.
Here is my simple smart contract :
pragma solidity ^0.5.0;
contract Subtract {
address payable public minter;
uint ...
2
votes
0
answers
1k
views
How to obtain the msg.sender in truffle console?
Here is my code snippet to return the msg.sender:
function showSender() public view returns (address)
{
return (msg.sender);
}
But when I try to call this function using this:
Coin....
3
votes
1
answer
3k
views
How to interact with my Rinkeby contract via truffle console?
I've been using truffle console to interact with a contract which I developed locally with Ganache. I'd like to be able to call the contract's methods using the console once deployed to the Rinkeby ...
0
votes
2
answers
2k
views
Truffle console keep showing "undefined". Solved by rolling back to v4 stable
I have updated my truffle version to the latest v5.0.3. By running truffle version, I can get the following version statements.
Truffle v5.0.3 (core: 5.0.3)
Solidity v0.5.0 (solc-js)
Node v10.8.0
...
0
votes
2
answers
609
views
Changing the format of numeric output in Truffle Console
When I return a Big Number in the Truffle Console, the format of my results is something like:
truffle(development)> tokenInstance.balanceOf(accounts[2])
<BN: 64>
However, in one of the ...
4
votes
2
answers
3k
views
Function "is not a function" in Truffle dev
I am not sure why I am being told my function is not a function.
I am doing calls as I always do from the Truffle console.
pragma solidity >=0.4.22 <0.6.0;
contract store {
string public ...
0
votes
2
answers
1k
views
Retrieve specific account in truffle 5 console
I am following a truffle tutorial where the individual users web3.eth.accounts to retrieve all the accounts from Ganash. However that seemed depreciated and to duplicate his results I used web3.eth....
2
votes
1
answer
473
views
What is the best way to test calling a contract's function from another contract?
I'm playing around w/ Gnosis' MultiSigWallet and noticed in their replaceOwner function it has a modifier that requires msg.sender to be the MultiSigWallet contract itself:
modifier onlyWallet() {
...
0
votes
1
answer
295
views
How to interact with a MainNet contract from a console?
This question may be really dumb, but I fail to understand how to do this.
I have deployed a smart contract to MainNet, and so far I've been interacting with it via Web3JS and Truffle (via the ...
0
votes
2
answers
653
views
Calling Truffle Commands through a script
I made following contract using visual studio code
pragma solidity ^0.4.17;
contract IDSCheck {
mapping( string => string ) PersonHash;
function AddHash(string name, string hash) {
...