Questions tagged [truffle]

Questions regarding the implementation and use of the Truffle development and testing environment.

Filter by
Sorted by
Tagged with
0
votes
1answer
27 views

Using the correct/best solc version with Truffle and general tooling setup

I haven't worked with Truffle/Solidity for a while and I am trying to get my environment/toolchain configure correctly. I have some questions regarding the compiler config. I was originally not ...
1
vote
1answer
23 views

Logic help needed, how to transfer funds to the address who placed bets on winning team?

This is a betting application and right now -> if I place bets on HOME, the amount gets stored but I want to transfer the amount only to the address who placed bets on winning team. I have developed ...
0
votes
1answer
30 views

How to Open console In geth 1.9.10

I am currently using geth in windows and 1.9.10LTS version of geth. I have to Open geth console, but when i try to implement geth console or geth attach or geth attach ipc:\\ .\pipe\geth.ipc it doesn'...
0
votes
1answer
8 views

Truffle test: “Cannot read property 'gasUsed' of null” error. Truffle migrate works fine

Whenever I try and do truffle test I get the error Cannot read property 'gasUsed' of null But truffle migrate --reset works fine More confusingly, to rule out something in one of my tests that is ...
0
votes
0answers
24 views

Not able to call the solidity function through App.js? Anyone know how to call a solidity function?

I'm trying to call a Solidity function from App.js, but I'm unsuccessful even after a number of tries. Its a very simple function betOnTeam(). Inside this function I just want to check condition and ...
0
votes
1answer
18 views

How to call such a function? (pass argument)

For example, here is the code What will the best code practice, either to repeat the code inside two different functions or what can I do? OraclizeContract.deployed().then(function(instance) { ...
0
votes
1answer
33 views

Enabling truffle compile optimizer does not change the deployment gas cost

I am trying to deploy my contract by enabling the optimizer to see how much I can save from the gas costs. I am using truffle for the deployment. In truffle I enable the optimizer by the following ...
0
votes
1answer
34 views

Function stopped working? No check is being done now on transfer function

I created a function to deposit and transfer ether and it was working great until i tried to deploy again and now the transfer function is not working anymore No errors are being thrown, the transfer ...
0
votes
2answers
32 views

Cannot transfer ether from smart contract to another address

I am using truffle and when we type truffle develop it provides us with 10 address ** So, the problem I am facing is I have created 2 functions one to deposit ether and the other one to transfer the ...
0
votes
0answers
15 views

How is this possible using web3 and truffle accounts [closed]

all i want is this Alice sends contract 1 Ether. Now contract has 1 Ether. Contract forwards 1 Ether to Bob. Now contract has 0 Ether. I know this is possible but to accomplish it with front end AND ...
0
votes
0answers
16 views

“truffle migrate --network ropsten” stuck after compiling

I am trying to redeploy a contract on Ropsten Testnet using the command: truffle migrate --reset -f 1567182283 --network ropsten Here, "1567182283" is the prefix of my migration file. Upon executing,...
0
votes
1answer
16 views

Redeploy contract on Ropsten Network

I have already deployed my smart contract on Ropsten network for testing using truffle suite. The command line I used was: truffle deploy --network ropsten Now, I have made some changes to my ...
0
votes
0answers
18 views

How can we send ether to smart contract address and then transfer it to a account? [closed]

Any ideas, code or suggestions is welcome I am using truffle ,web3 ,metamask Can we send rawtransaction to contract address and then Retrieved the amount? I need to deduct amount from 2 people ...
0
votes
0answers
50 views

Cant call solidity function from app.js?

Solidity function Using web3 0.20 version and Cant call solidity BETONTEAM function pragma solidity ^0.4.22; import "installed_contracts/strings.sol"; import "installed_contracts/oraclize-api/...
0
votes
0answers
17 views

How can i transfer ether upon callback from Oraclize/Provable? [closed]

I am a newbie any help is highly appreciated I know how to send call to oraclize finally, and how to transfer ether between two accounts using web3,metamask But How can i transfer this fund when ...
0
votes
0answers
29 views

Cant call solidity function from app.js while sending transaction

Solidity function As i want to call function so that oraclize can send query function betOnTeam(uint team) payable public { update(); emit LogInfo("Oraclize query was NOT sent, ...
0
votes
1answer
23 views

Can someone explain the difference between using metamask or web3 to send ether from truffle accounts?

I am using web3 and truffle (i am a newbie wants to understand concept) I need to transfer ether so i understand that i need to use web3.eth.sendtransaction But will it work as i am using localhost ...
0
votes
1answer
22 views

Can we take input of an address and pass it on the function to send ether using truffle and web3?

Actually i am trying to create a betting application so when i get the result that Home team has won Before this i will be taking both address as input (betting do two address whoever wins gets the ...
0
votes
1answer
32 views

How to encode an object with ABIEncoder V2?

How to encode an object with ABIEncoder V2? For example, this one: { items: [ { str: "str", num: 5, bol: true } ] } Solidity struct: struct Item { string str; ...
0
votes
1answer
32 views

Getting stuck in truffle testing

I am trying to run a test and I am getting the following message; I have tried the following; npm install scrypt npm install web3 as to solve the yellow message and when running truffle test ...
1
vote
2answers
24 views

How to read data returned by a function? [duplicate]

Counter.sol: pragma solidity >=0.5.0 <0.7.0; contract Counter { uint public _counter = 0; function GenNextID() public returns (uint) { return _counter++; } } I use ...
0
votes
2answers
28 views

Function, variable, struct or modifier declaration expected [duplicate]

I am using the following code structure; pragma solidity ^0.5.0; contract TtdmToken { uint256 public totalSupply; function TtdmToken () public { totalSupply = 1000000; } } ...
0
votes
0answers
48 views

How to call solidity function from javascript file? Keep getting error deploying through truffle and webpack

Error -> TypeError: fetch.amount is not a function [WDS] Disconnected! Please explain or provide code on how to call solidity function Trying to call from ready() function console.log(contract.abi)...
1
vote
1answer
14 views

Setting sending account in Truffle test

I need to create contracts from various accounts in a Truffle JS Test. To do so, I set: let accounts = await web3.eth.getAccounts(); MyContract.web3.from = accounts[9]; Before creating my contract ...
2
votes
1answer
16 views

Telling Truffle to ignore certain files

Whenever I edit a file called filename.something, my text editor creates a file called .#filename.something when I modify anything. That file exists until I save. These files never were a problem ...
1
vote
1answer
29 views

Invalid number value when deploying contract using truffle? But how to fix it in code is the value or _amount variable ?i cannot figure it out

2_deploy_contracts.js Replacing 'OraclizeTest' Error: * Deployment Failed * "OraclizeTest" -- invalid number value (arg="_amount", coderType="uint256", value={"from":"...
0
votes
2answers
38 views

Truffle best practices - unit vs integration tests

Think about having two contracts: MockToken Faucet (which takes token address as constructor parameter) To unit test Faucet I would create two new instances: const token = await MockToken.new() ...
1
vote
2answers
22 views

Test using async/await in truffle not working

I am using node v12.13.1, truffle@5.1.8 and ubuntu 18.04 and running the test using documentation of async/await. https://www.trufflesuite.com/docs/truffle/testing/writing-tests-in-javascript#using-...
0
votes
1answer
25 views

how can someone use the smart contract deployed on Rinkeby network? what are next steps after successful deployment? [duplicate]

I am new to the smart contract and blockchain technology but learning step by step. I developed a small bidding smart contract in solidity. Using Truffle, NPM and Infura, I deployed it in the Rinkeby ...
0
votes
0answers
36 views

Can someone use and test the smart contract written in solidity deployed in Rinkeby network? [closed]

I am new to the smart contract and blockchain technology but learning step by step. I developed a small bidding smart contract in solidity. Using Truffle, NPM and Infura, I deployed it in the Rinkeby ...
0
votes
0answers
22 views

Truffle - set or disable optimizer only for selected contracts

I have over 40 contracts in my project, for example: admin groups votings registry token In my truffle config I have optimizer enabled with 600 runs. compilers: { solc: { version: "0.5....
0
votes
0answers
26 views

Testing of 2 Smart Contracts using Truffle

I'm writing 2 smart contracts: one is a satellite of the other. That is contract A is calling contract B. When I migrate in truffle all is OK, but when I try to run the tests it is not working. Is ...
0
votes
0answers
48 views

Smart contract works on remix and ganache but not on private chain developed by geth

The smart contract works well on the ganache and remix but not work on the private chain, even though i use the --testnet geth --identity "EDU" --rpccorsdomain "*" --rpc --rpcport "8545" --...
0
votes
1answer
19 views

Could not deploy on Ropsten network using Truffle

I have following truffle-config.js file const fs = require('fs'); const HDWalletProvider = require("truffle-hdwallet-provider"); const secrets = JSON.parse( fs.readFileSync("abc.txt").toString()....
0
votes
1answer
25 views

TypeError: balance.toNumber is not a function

I need check that token has no balance when selfDestruct was called, but shows an error that balance.toNumber is not a function in the test file. DappTokenSale.sol function endSale() public { //...
0
votes
1answer
31 views

How to create account using mnemonic words or private key in web3js and call contracts using that account

I have a simple React Project with web3@1.2.4 installed and I want to call a contract's method like this: await maincontract.methods.CurrentMethod("arguments").send({ from: accounts[0]/*my account ...
0
votes
0answers
51 views

Mocha timeout when running truffle test. Works fine on ganache, not on public networks

This is the error I get when running truffle test --network kovan: 1) "before all" hook: prepare suite Error: Timeout of 120000ms exceeded. For async tests and hooks, ensure "done()" is called; if ...
1
vote
1answer
44 views

How could return events of specific args?

In my solidity contract, I just have one event which is: transferOwnerShip (uint id, address indexed newowner); and I want to filter the events log in order to retrieve only the events that belong ...
1
vote
1answer
31 views

I got this error during truffle testing. AssertionError: it returns true: expected { Object (tx, receipt, …) } to equal true

DappToken.sol function transfer(address _to, uint256 _value) public returns (bool success){ require(balanceOf[msg.sender] >= _value); balanceOf[msg.sender] -= _value; balanceOf[...
4
votes
3answers
60 views

I got this error during migration in truffle. : ParserError: Expected '(' but got identifier

This is my smartcontract code pragma solidity ^0.5.0; contract DappToken{ uint256 public totalSupply; constructor DappToken() public{ totalSupply = 10000; } } This is code for ...
1
vote
0answers
27 views

Is there a way to deploy a contract using bytecode only (to Ropsten …)?

One solution on medium.com describes how to do that via myetherwallet but it's the old verion of myetherwallet where you can switch between ropsten/mainnet - right now I can't find how to switch to ...
1
vote
1answer
36 views

Metamask Signing gives different signature than web3.js

I have successfully been using metamask to sign EIP712 data. I am currently trying to write truffle tests and need to replicate the signing process outside the browser. The issue I am facing is that ...
1
vote
0answers
18 views

Invalid implicit conversion from int_const 0 to address requested [duplicate]

Invalid type for argument in a function call. Invalid implicit conversion from int_const 0 to address requested.
0
votes
0answers
11 views

Truffle to Ropsten Testnet Deployment Issue: No migration

I am trying to deploy my contract on Ropsten test network through Truffle Framework. I use the command truffle migrate --network ropsten. Following is my truffle-config.js: const HDWalletProvider = ...
2
votes
1answer
22 views

Check emitted event with BN

I'm currently testing events that include numeric values: const level = new BN(1); truffleAssert.eventEmitted(tx, 'EventName', {level}); As you can see, the level variable is a BN, and holds the ...
0
votes
1answer
136 views

npm ERR! code ENOENT npm ERR! syscall spawn git

I use the command npx truffle unbox react to develop a dapp but I get these errors below in my console. Can anybody help me? I really don't know how can I solve them.
1
vote
1answer
56 views

truffle unbox pet-shop gives DownloadingError: read ECONNRESET at TLSWrap.onStreamRead (internal/stream_base_commons.js:201:27)

Ubuntu 18.04. Truffle v5.1.2 (core: 5.1.2) Solidity v0.5.12 (solc-js) Node v13.2.0 Web3.js v1.2.2 When I execute truffle unbox pet-shop on terminal, I get error ✔ Preparing to download ⠼ ...
1
vote
1answer
27 views

Truffle js test. Test not really testing

I have this tests that supposedly pass (in the terminal, I can see the checks). But they never actually run the code: it("should add an exam to the exams list", () => { let hash_test = "...
1
vote
1answer
85 views

Error Installing Truffle [closed]

OS: Ubuntu 18.04 I am following this guide (https://www.codeooze.com/blockchain/ethereum-dev-environment-2019/) to install Ganache, npm, and then Truffle. Everything is fine till I execute sudo ...
0
votes
1answer
60 views

RPC error when interacting with contract using Ganache GUI, but it works fine when using Ganache CLI

I have a truffle project, if I migrate it onto ganache-cli and then interact with my contract (via Metamask) it works great. But if I try and do the exact same thing using ganahe-gui the contract ...