Questions tagged [truffle]

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

Filter by
Sorted by
Tagged with
0
votes
0answers
15 views

uint parameter could not pass as a correctly in truffle test

How can I send a uint parameter value to the contract in truffle? i have a function that has two uint parameter and I wrote test that function but I guess the uint parameters cannt be sent as a ...
0
votes
1answer
23 views

uint value usage as a parameter in truffle

How can I send a uint parameter value to the contract in truffle? i have a function that has two uint parameter and I wrote test that function but I guess the uint parameters cannt be sent as a ...
0
votes
1answer
11 views

Test for Require statement in Truffle

I wrote a function that generate a key value. the function codes is here mapping(string => bool) processedHash; mapping(uint => bool) HashList; function generateHash(uint256 ...
0
votes
1answer
7 views

Block.timestamp returning multiple values

I have a function inside my smart contract that fetches the timestamp of the block it's in: function getTime() public returns (uint256 time){ return block.timestamp;; } According to how I ...
0
votes
1answer
9 views

Truffle Test: Setting blockTime

I'm using Truffle and I want to increase the blocktime to mimic that of the mainnet when i run my tests. As i understand it, Truffle has already instantiated a web3 instance that's ready to use so i ...
0
votes
2answers
18 views

How to prevent someone to replace our smart contract

I'm still learning to develop dApp and currently, I conduct some testing on my dApp. I found out that someone who is part of the blockchain network (miner and node) can replace our deployed smart ...
0
votes
1answer
8 views

When i am doing migration, the netwrok name is ganache instead of development and multiple errors are there

D:\>truffle migrate --reset Compiling your contracts... =========================== > Compiling .\contracts\Migrations.sol > Artifacts written to D:\build\contracts > Compiled ...
1
vote
1answer
22 views

Value of emitted events in App.js

Actually in my App.js I have called my contract function like this: [ this.state.swapcontract.methods.sendFunds(address).send({ from: this.state.account , value:amount}) ] The function is called ...
1
vote
1answer
19 views

TypeError: tests is not a function Error in Truffle

I am following an online tutorial, doing almost exactly like the instructor. I have the following error every time I try to run 'truffle test' my truffle-config file: module.exports = { // See &...
1
vote
0answers
11 views

Truffle compiler stuck at 0.4.17

Coming from here: How do I specify a different Solidity version in a Truffle contract? I still have the same issue, except that even after trying all of the suggested solutions, and even having the ...
1
vote
0answers
16 views

How to sign transactions using Metamask and send the signed transaction to NodeJS so that it can be added on Ropsten Infura?

I have developed a secure file sharing application in NodeJS(v10.16.1) + Express(v4.17.1) + Truffle(v5.1.15) + Metamask(v7.7.8) which works perfectly on localhost. I am using @truffle/contract(v4.1.11)...
1
vote
2answers
39 views

web3 - Error when calling sendTransaction with @truffle/contract on Ropsten Infura

My smart contract is already deployed on Ropsten TestNet provided by Infura at 0x63865E0F065C7b865e1a2EE4d99C383A414Bec22 address. I want to sendTransaction using NodeJS(v.10.16.1) + Web3(v.1.2.6) + @...
1
vote
1answer
20 views

Testing solidity transfer method not transferring tokens

I have this solidity contract: contract Token { mapping(address => uint256) public balanceOf; event Transfer( address indexed _from, address indexed _to, uint256 _value ); ...
0
votes
1answer
23 views

With TRUFFLE: Call public function of contract from within another contract

Similar to How do you call a function of a deployed contract from another contract? (first answer), but because Truffle has access to the ABI's of compiled contracts thought I could avoid low-level ...
2
votes
1answer
24 views

VM Exception while processing transaction: out of gas

I have this crontract: pragma solidity ^0.6.0; pragma experimental ABIEncoderV2; contract Tickets { struct Ticket { uint serie; uint number; uint datetime; } Ticket[] tickets; ...
0
votes
0answers
26 views

Truffle test using multiple connections

I am running a test which involves sending transactions to a smart contract from multiple nodes. Right now, I have seperate truffle folders in each node, with a test file that sends the transactions ...
0
votes
1answer
24 views

Smart contract transaction takes different amounts of gas on different platforms

I have an ERC-20 token contract on which I want to perform some testing on a local chain. I got my chain setup, contract deployment and testing scripts ready on my Windows machine. However, since I ...
0
votes
1answer
22 views

What is .new()?

I am using the following code to deploying a smart contract to a private network with Node-js. But the error TypeError: contract_object.new is not a function occurs. What are .new() and the error's ...
1
vote
1answer
24 views

How do we compile a contract with pragma solidity 0.5.7 to work with hardfork `istanbul`?

I am using Truffle to compile the contracts and by default it compiles the contracts with pragma solidity 0.5.7 to evm version petersburg. Is it possible to compile the same contract for evm version ...
0
votes
0answers
21 views

Error: VM Exception while processing transaction: revert at PromiEvent When calling variable function from the deployed contract variable

I am new to blockchain and development and learning from the dapp university tutorial. I have created a contract Todolist.sol pragma solidity ^0.5.0; contract TodoList{ uint public ...
0
votes
0answers
15 views

How can you test with a mock when the address is hard coded in the real contract?

For testing purposes, is there any way to replace a contract referenced by a hardcoded address with a mock? I'm defining an interface in my contract address interfaceAddress = 0x...; IInterface if = ...
1
vote
1answer
222 views

Getting Error while compiling: Stack too deep

Here is my code i have array not 16 variables in a function please help where i am wrong. struct Escrow { bytes16 contractID; uint256 sellingTokenAmt; uint256 feeAmtInSellingToken; ...
3
votes
1answer
62 views

Alternatives for Truffle for running and writing tests

Truffle offers many conveniences for writing tests for Ethereum smart contracts. The benefits include no need for a separate chain process like Ganache, complex automation of linking and deploying of ...
1
vote
1answer
21 views

ganache-cli: Returned values aren't valid, did it run Out of Gas?

This issue is simple to replicate using an Ethereum Grid (Geth) node, ganache-cli and truffle. After starting the (light) Geth node: 1. Fork mainnet from Geth node ganache-cli --fork http://...
0
votes
0answers
14 views

Unpacking Open Zeppelin starter pack warnings and errors

When unpacking OZ starter pack I get a couple of 100 lines of red code (warnings) and then it ends with a bunch of errors (see below). npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! sha3@1.2.3 ...
1
vote
0answers
23 views

Best way to run tests in Truffle for contracts that rely on mainnet dependencies?

I could create mocks of the dependencies but I'd really like to be able to fork mainnet using Ganache in a way similar to this (https://medium.com/@samajammin/how-to-interact-with-ethereums-mainnet-in-...
0
votes
0answers
35 views

Error: [number-to-bn] while converting number “test” to BN.js instance

I'm trying to deploy the contract which does not use number to bignumber conversion itself. But I'm getting the following error about the code from node_modules: Error: Error: [number-to-bn] while ...
0
votes
0answers
22 views

Truffle revert when deploying contract

solidity newbie here working on moving from remix to truffle suite. I have a contract that worked fine on remix but is raising the following error message when attempting to deploy to local test chain ...
2
votes
1answer
21 views

truffle version and solcjs --version returns different versions

I want to change solc version on my system(downgrade from 0.5.16 to 0.4.17). I tried uninstalling it with npm -g uninstall solc and then installed with npm -g install solc@0.4.17 but it does not ...
0
votes
1answer
44 views

Error : Number can only safely store up to 53 bits

Hi I am trying to run the following tests var chai = require("chai"); var chaiAsPromised = require("chai-as-promised"); chai.use(chaiAsPromised); var expect = chai.expect; var Bet = artifacts....
1
vote
1answer
20 views

Display the value of a smart contract's variable with Truffle External Script

I will like to display the value of a variable in an existing smart contract in Truffle. Here's my script: module.exports = async function(callback) { const project = artifacts.require("project"); ...
1
vote
1answer
20 views

How to use solidity library with truffle

I'm using truffle V5.1.13 and when I run truffle test the res variable contains a transaction receipt rather than the expected 2. I notice if I remove everything that has to do with the library things ...
1
vote
1answer
31 views

Watching events with truffle test

Given following solidity code: pragma solidity ^0.5.1; contract Foo { event FooInc(uint256 _a); uint256 a; constructor() public { a = 42; } function inc() public ...
1
vote
2answers
34 views

Can the mapping storage change after contract deployment?

I am beginner in mapping.I work on Truffle and Ganache. I deploy the following contract: pragma solidity ^0.5.12; contract customerFinder{ mapping(uint256 => address payable) public ...
0
votes
1answer
26 views

Convert big number to regular number [duplicate]

I call let inst = contract.deployed() and then on inst I can then call mybn = units.then(function(inst) {return inst.getBN()} mybn looks like this BN { negative: 0, words: [ 1, <1 empty item&...
1
vote
0answers
52 views

Error: project ID is required

I have a truffle project which was running on another machine without problem. But now I'm trying to npm install and I'm getting this error: >truffle install Error: project ID is required at ...
0
votes
0answers
14 views

I got the error when I do 'truffle test' in Truffle tutorial that pet-shop-tutorial

I'm doing truffle tutorial the pet-shop-tutorial but when I typed truffle test in cmd, I got the error. Here is the error message. I have no idea how I can fix it and where should I check. Please ...
0
votes
0answers
14 views

Truffle develop freezing. Trying to check variable values

truffle-config.js module.exports = { compilers: { solc: { version: "^0.6.0" } }, networks: { development: { host: "127.0.0.1", port: ...
0
votes
0answers
9 views

Aragon: How to update files after a contract compiles

I need to update certain files (in app/public/) every time when a contract compiles. Namely I need to extract the ABI from a contract and store in app/public/. Is it possible with the current version ...
0
votes
1answer
16 views

Only 1 .SOL contract file is compiled in truffle project

I am having a very annoying problem but hopefully very simple to solve! I have a truffle project. In my contracts directory I have 2 files: > 1_Migrations.sol > 2_Factoring.SOL When I ...
0
votes
1answer
53 views

Cannot create contract from another contract - truffle and ganache

I'm trying to write a test with ganache and truffle to create a contract instance from another contract. Everything works in Remix but it doesn't in ganache. This is the code const assert = require('...
0
votes
0answers
14 views

Truffle contract bytecode not updating with library address

After deploying a library using truffle, I want to compile a contract and use the library address inside its generated bytecode. Now inside the contract bytecode I get something like _DateTime______. ...
0
votes
0answers
18 views

ParserError: Expected token Semicolon got 'Return'

The error pops up whenever I try to compile through truffle, not able to figure out a solution any help is highly appreciated. Here is the error Compiling your contracts... ==========================...
0
votes
0answers
24 views

Migrating 2 contracts in one Contract.sol script using 'truffle migrate'

I have 2 contracts in 1 .sol file and when I run 'truffle migrate', it tells me that it has deployed 1 of the contracts and given me an additional error: Blockquote Invalid number of parameters ...
1
vote
0answers
17 views

What are the differences between Drizzle and the Truffle React box?

Truffle has many "boxes", two of which are: truffle unbox react And: truffle unbox drizzle They both seem to be focused on frontend development. Other than Drizzle being based on a Redux store, ...
0
votes
0answers
13 views

Automatically set app instance in Truffle console

Is there a way to load the truffle console with the following variables without having to do manual type-ins on every test? let app = await MyContract.deployed(); let accounts = web3.eth.getAccounts()...
0
votes
1answer
30 views

Importing OpenZeppelin loads all node_modules contracts into Ganache

I install OpenZeppelin's contracts npm install @openzeppelin/contracts Create a contract: pragma solidity ^0.5.0; import "@openzeppelin/contracts/token/ERC20/ERC20Mintable.sol"; contract NewCoin ...
0
votes
1answer
32 views

How to pass parameters into test script

I have a voting solidity file here: pragma solidity >=0.4.21 <0.7.0; // We have to specify what version of compiler this code will compile with contract Votingapp{ /* mapping field below is ...
0
votes
0answers
14 views

Tuffle. New account from mnemonic during migrations

I'm trying to create a new account from predefined mnemonic during Truffle migrations(both testing and prod environments). I want to pre-create multiple contracts using corresponded factories for this ...
0
votes
0answers
21 views

XMLHttpRequest() does not work probably in a Truffle project

I want to connect to my smart contract in a Truffle project and get some information from it. The smart contract's name is "TEST". The follow is my app.js code that should communicate with my smart ...

1
2 3 4 5
42