Questions tagged [truffle-contract]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
26
votes
12answers
22k views

How to upgrade solidity compiler in truffle

I couldn't find a way to upgrade a version of truffle solidity compiler. Also curious how to see that information for deployed contracts in truffle console
25
votes
4answers
4k views

what does `deploy.link` exactly do in `truffle`

Please explain use cases for deploy.link() function in migrations in truffle framework. How would you use it and for what.
18
votes
1answer
14k views

Steps to deploy a contract using MetaMask and Truffle [closed]

i'm noob, I want to deploy my contract on Ropsten network with MetaMask & Truffle, plz explain to me the steps to deploy it.
12
votes
3answers
3k views

Truffle & Web3 1.0.0-beta : does it work for anyone?

I'm trying to make the latest Truffle (3.4.3) and Web3 (1.0.0-beta11) to work together in a React app. It fails when I try to call myContractInstance.deployed() import { default as Eth} from 'web3-...
11
votes
3answers
6k views

Truffle invalid address

With Truffle 3.0 when I call one of my contract's function, in console I have this error: Uncaught (in promise) Error: invalid address I found this workaround, and in my code I try this with no ...
7
votes
2answers
1k views

Debugging JS unit tests with truffle framework in VS code

Is there a way to debug JS unit tests for smart contracts? I use VS Code for development, and when I try to run a Mocha debugger it complains that artifacts is not defined. I briefly looked at truffle ...
7
votes
2answers
3k views

Difference between truffle-contract and web3.eth.Contract

maybe this is a very simple question but I've tried unsuccesfully to understand the difference between truffle-contract and web3.eth.Contract from web3.js 1.0. As far as I've understood they seems to ...
5
votes
4answers
4k views

How to access the deployed contract's address from Truffle JS tests?

I've written a test that involves returning the token balance that the contract itself holds. In the contract source file I would access the balance using the function getBalanceOf(this). However, ...
5
votes
4answers
892 views

Unhandled promise rejection(gas limit) when deploying Contract to rinkeby using truffle-hdwallet-provider

I am trying to Deploy a beginners contract onto the rinkeby test network through Infura node. It is throwing the following error. (node:35183) UnhandledPromiseRejectionWarning: Unhandled promise ...
5
votes
3answers
2k views

accessing truffle contract abstractions from external JS script

When writing tests in truffle (v3.2.1) I can forget about things like a contract's ABI and address and just use ContractName.deployed() to interact with a contract on my testrpc chain. How can I mimic ...
5
votes
1answer
418 views

Best practice for sharing truffle build files between developers

I am working on a few projects using truffle, as you know truffle compiles and migrates contracts to various ethereum networks e.g. MyContract.sol produces MyContract.json which contains a reference ...
5
votes
1answer
1k views

Contract migration error: The contract code couldn't be stored, please check your gas amount

I am trying to deploy my simple ERC20 token with locally installed Truffle, but received this error: truffle migrate --reset Using network 'development'. Running migration: 1_initial_migration.js ...
5
votes
1answer
297 views

Using truffle migrations for seeding lots of data inside a smart contract?

I have been developing a smart contract (ERC-721 compliant) which needs to be populated with lots of various pieces of data. Approximately 300 ERC721 tokens need to be minted inside the contract at ...
5
votes
1answer
465 views

Printing uint256 value to console while debugging with Truffle

I am trying to figure out how to print values to the console while doing truffle debug <txhash>. So far I have tried using an event called "TestValue", but I am not seeing the output in the ...
4
votes
1answer
4k views

Expected identifier, got 'LParen'

I try using IterableMapping by this example. I have error when I compiling contract by truffle: Expected identifier, got 'LParen' This is my code: pragma solidity ^0.4.15; import "./itMapsLib....
4
votes
0answers
502 views

How can I retrieve transaction hashes using web3 batch requests?

When I send a transaction using Truffle's contract wrappers - or using plain web3 sendTransaction() - I get a tx hash back that I can use to confirm the tx has completed. While using batch requests (...
3
votes
1answer
8k views

how to know the contract address which truffle is deploying with

I am using truffle migrate --reset --compile-all to deploy the contract to local network but in order to use new web3.eth.Contract(jsonInterface[, address][, options]), i should be able to know ...
3
votes
1answer
1k views

How to convert BigNumber returned by Truffle Console [duplicate]

I have a simple contract Foo which is deployed to a Ganache network. pragma solidity ^0.4.18; contract Foo { uint storageData; function set(uint x) public { storageData = x; } ...
3
votes
1answer
2k views

Truffle error: Cannot read property 'call' of undefined [duplicate]

I am trying to run the following contract in truffle, which is pretty much the same HelloWorld but I kept the name MetaCoin from the truffle example. I have read this, this, and this posts related to ...
3
votes
1answer
601 views

truffle test - not able to understand why the control jumps to different test case

I am trying to write unit test cases in truffle framework.I am able to write and execute them. However, whenever I have 2 or more test cases the control jumps from 1 test case to another. For ex: In ...
3
votes
2answers
1k views

Truffle on Windows 10: how to unlock an account for migration to a private network

I try to migrate a smart contract to a private network via truffle on Windows 10. I specify a certain account in truffle.js and so far I get the following error: Error encountered, bailing. Network ...
3
votes
1answer
2k views

Convert hash function hex to bytes32

The output of hash function SHA256 is a hex string of size 64. For example: 3ed54831f488a22b28398de0c567a3b064b937f54f81739ae9bd545967f3abab I want to call the function of a smart contract with the ...
3
votes
1answer
342 views

Truffle Test: How to test SafeMath Library for overflow

How can I test if a function is resistant against overflow with truffle test? contract SafeMath{ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b;...
3
votes
1answer
252 views

How to include an other contract from a different folder while unit-testing with truffle?

The folder structure is as follows: Examples | +- Multiply | +- Solidity | +- contracts | +- MultiplyContract.sol | +- UUIDProvider ...
3
votes
1answer
267 views

Invalid Opcode when sending Eth to open zeppelin crowdsale on testrpc

I've been working on getting a crowdsale contract working using the Open Zeppelin library and Truffle for a couple of days now. I can get the basic crowdsale working, but as soon as I try to ...
2
votes
2answers
2k views

How to generate truffle artifact for already deployed contract for use with web3

I'm building a dapp and would like to interact with an already existing contract. Previously working with Truffle I was writing my own contract, compiling it and deploying it. This process generated ...
2
votes
2answers
350 views

What is the {from: account_one} third parameter in metacoin.js test example

When working through the MetaCoin sample project; within the MetaCoin.sol file we have this method: function sendCoin(address receiver, uint amount) returns(bool sufficient) { if (balances[msg....
2
votes
2answers
737 views

When using array.push in solidity contract the logs is empty (using truffle-contract)

When I run the below solidity function: function startAuction(string name, uint timeLimit) public returns (uint[]) { uint auctionID = totalAuctions++; AuctionStruct a = Auctions[auctionID]; ...
2
votes
2answers
127 views

Is drizzle a contracts lib?

I'm researching about smart contracts, and been seeing a lot of truffleframework, ganache and drizzle. In the other hand, only found broad descriptions of those tools: "Drizzle is a collection of ...
2
votes
1answer
210 views

Calling contracts inside for() loop [closed]

I have .js file, where the contract has to call five times by passing rand as parameter. But rand has been overwritten and only the fifth random value is passed to the contract five times: for(var i=...
2
votes
2answers
1k views

Truffle - Migrate Contract to a private network in Azure

I try to migrate a Smart Contract to a private network running in Azure. It works fine with testrpc but when I try to migrate it to the (remote) private network I always get the following error: ...
2
votes
2answers
2k views

TypeError: Web3 is not a constructor when trying to use node.js with truffle-contract

I'm trying to use node.js with my smart contract for my app. As I've tried to convert from using the default app.js set-up to index.js set-up I've ran into this weird issue I can't fix. It throws ...
2
votes
2answers
446 views

Truffle test promise that expectedly throws error

I have contract with methods that check input parameters using require(bool) so if at least on of conditions does not matched it throws an error. During test procedure (using Truffle and Chaijs) it ...
2
votes
2answers
267 views

Difference of behavior between Metamask and direct connection to testrpc

I’m guessing there is an obvious answer to this question but I’m just completely missing the point. I have a very simple contract with 2 functions: a setter that changes a bunch of fields, and a ...
2
votes
1answer
136 views

TruffleContract At() function with Drizzle

I am learning the Drizzle framework after I did a project using TruffleContract abstractions in Javascript (DApp). I have multiple instances of a contract and I am not able to access at the instances ...
2
votes
1answer
171 views

Truffle-contract installed, but receiving error in Chrome console: Uncaught Error: Cannot find module 'truffle-contract'

I am working on my first end to end ethereum project. A problem that I am stuck on is that I have installed 'truffle-contract', but when I run my server and open the project in the Chrome browser, the ...
2
votes
2answers
65 views

Working of Truffle

The following is my code in solidity pragma solidity ^0.4.2; contract DappToken { //Constructor // set no of Tokens // Read the total number of Tokens uint256 public totalSupply; ...
2
votes
1answer
506 views

Is it possible to connect with infura without a web3 provider?

I am trying to implement fallback funcationality for my DApp which means that when no web3 provider (e.g. metamask/trustwallet etc) is found I can still make calls to the ethereum network but I always ...
2
votes
1answer
921 views

UnhandledPromiseRejectionWarning: Error: Web3ProviderEngine does not support synchronous requests

I've been struggling on this for days, and been googling a bunch of things but still no luck. Here's my code for 2_deploy_contracts.js: const CoinCrowdsale = artifacts.require("./CoinCrowdsale.sol") ...
2
votes
1answer
257 views

Unable to transfer ether to a contract from a account in truffle. Getting Exception VM Exception while processing transaction: invalid opcode

I am trying to simulate send ether fail in KingOfEther contract: The contract is specified below. contract KingOfEther { address public king; uint public claimPrice = 20; address owner; ...
2
votes
1answer
507 views

Truffle work over HTTPS

I installed my own ethereum node and put it behind HTTPS nginx proxy. geth attach works perfectly but truffle deploy failed with error: <html> <head><title>400 The plain HTTP ...
2
votes
1answer
98 views

Ethereum Contract testing

I'm trying to test one of my functions in a contract which returns a bool value, and in the process of debugging I tried to retrieve the output using console log and I get the following hash: ...
2
votes
1answer
716 views

Truffle and contract with an Address type constructor parameter

When I add new contract (testrpc) with truffle with parameter of type "address" the reading value of this property seems wrong (always 0x0000000000000000000000000000000000000000), I do not find the ...
2
votes
1answer
424 views

Cannot deploy contract on private network with truffle: gas required exceeds allowance or always failing transaction

I'm writing a contract based on the ring mixer contract from here https://ropsten.etherscan.io/address/0x5e10d764314040b04ac7d96610b9851c8bc02815 I've tested it with ganache. Everything worked fine ...
2
votes
0answers
73 views

this.contract.deployed() is not a function

I'm working on making a React frontend for my smart contract, but I'm having problems connecting it into my React code. Here are the relevant portions of my code: import TruffleContract from '...
2
votes
0answers
138 views

Installing Truffle without npm

I'm a student trying to install a truffle test RPC client (just for simple contract deployment in small scale). I am using a remote Ubuntu machine in my university, and i don't root privileges. ...
2
votes
2answers
126 views

Truffle interaction with my smart contract getting Vm exception

pragma solidity ^0.4.23; contract Hotelbooking { event Transfer( address indexed _from, address indexed _to, uint256 _value ); mapping(address => uint256) public ...
2
votes
1answer
295 views

Pending transactions are not mined

Preconditions I'm running a private network with Geth, having custom smart contracts deployed by Truffle and a simple frontend which using Metamask as a provider to connect the network. Versions ...
2
votes
0answers
130 views

Frontend call --> Transaction does not go through, no error message displayed

I'm trying to build a frontend for my Dapp and first, I wanted to test if I can initiate a transaction at all. I have a Button which calls the storeInput() function. Then, it should invoke the ...
2
votes
3answers
533 views

writing tests in solidity for functions returning multiple values

I have a function that returns multiple values function getInfo(string id) returns(string x,string y){ bytes32 _id= strToBytes(id); return (infostruct[_id].x,infostruct[_id].y) ; } Now i want ...