39

You can force truffle to use a specific solc version by installing that version directly in the truffle directory. For example on Ubuntu the following with force truffle to use 0.4.15 $ cd /usr/local/lib/node_modules/truffle $ npm install solc@0.4.15 truffle version will still show the default version but it will in fact utilize the updated version. You ...


31

Solution 1: With you own node You can easily deploy on the ropsten network if you own a full node running on your machine. i. Run geth $ geth --fast --cache=1048 --testnet --unlock "0xmyaddress" --rpc --rpcapi "eth,net,web3" --rpccorsdomain '*' --rpcaddr localhost --rpcport 8545 ii. In truffle.js, add the following configure for the ropsten network ...


17

EDIT: As stated in the comment by @feihcsim autolink has been deprecated Let's say ecosystem of your dapp has a library and a contract that calls functions from that library. So you have: library Converter { function weiToEther() returns (uint256) { //return ether value } } Then you have contract: import "Converter.sol"; contract MainContract { ...


16

There are a few ways to do this: 1) In your blockchain node (testrpc|ganache or your test/live network with geth/parity), the contract deployments will be logged and you can see the address created then Transaction: 0xc2471aa6d1e020921d41247ac2a86eb5ad2447e93450347365a25f8d632e34bd Contract created: 0x98445ab3eaafdd2293981525631730c64adec41a // <--- ...


13

Thank's to Truffle Gitter channel I figured out. I have to call defaults function on my truffle-contract's abstraction. MyContract.defaults({from: …}) https://github.com/trufflesuite/truffle/tree/develop/packages/truffle-contract buildContracts() { let contracts = {}; let meta; this.props.contracts.forEach( _contract => { let {...


12

If you're using ^v5.0.0 (including beta releases), you can bring your own compiler by adding this in your truffle config file (in this example it's set to 0.4.25): module.exports = { ... compilers: { solc: { version: "0.4.25", }, }, ... }; You can query the list of available compiler versions by running this: truffle compile --list


10

Your lucky day (had to solve this few days ago): See that you have truffle-core locally in your project. If not, do: npm install truffle-core Then use a configuration similar to this: ( Debug -> Open Configurations ) { // Use IntelliSense to learn about possible attributes. // Hover to view descriptions of existing attributes. // For more ...


9

After a couple of attempts, I've made it by uninstalling and installing truffle, exactly as described in here: npm uninstall -g truffle npm install -g truffle That updated Truffle itself though, along with the compiler.


7

I was able to make it work with recently released truffle-contract. web3@1.0.0-beta.20 truffle-contract@3.0.0 truffle@3.4.9 Issues for me so far: doesn't work with http provider: "TypeError: Cannot read property 'apply' of undefined" UPDATE: there is a workaround for this issue, check the comments on the issue linked Page refresh in browser makes web3 ...


7

I added '0x' + in front of the bytecode in the .deploy to make it Work. .deploy({ data: '0x' + bytecode, arguments: ['Hi there!'] }) If there's no '0x' the bytecode will convert the whole string to hexadecimal, which will be double the size and throw the gas error. I also re-installed truffle wallet provider using $ sudo uninstall truffle-hdwallet-...


6

You need to upgrade your truffle to do that. npm install -g truffle@X For example, to get solc 0.4.11 support, install truffle 3.2.2 or above. npm install -g truffle@3.2.2 or npm update -g truffle@3.2.2


5

There is several problems with your code. You copy paste the function prototype instead of calling it you should use im_myAddressUintMap.insert( key, value); And you have to make this insert inside a function or inside the constructor ( function with the name of the contract ) function insert( address key, uint value ) public { im_myAddressUintMap....


5

As pointed out by @Ismael in the comment and after some days spent working with both library I can confirm what he has written. Truffle-contract is based on the stable version of web3 (v0.20), so it use promises and allow you to perform contract operation and methods in Javascript. Web3 v1.0.0 (which is still in beta) use Promise and Promievents, so web3....


4

Not sure whether this is the intended way, but experimenting with bits and pieces of code found around the Internet resulted in something that seems to be working. Here's what I did in my javascript app: .... const artifacts = require('../build/contracts/MyContract.json') const contract = require('truffle-contract') let MyContract = contract(artifacts); ...


4

in truffle you always need to add this object parameter representing the values you need for transactions in Ethereum. like in: eth.sendTransaction({from: '0x036a03fc47084741f83938296a1c8ef67f6e34fa', to: '0xa8ade7feab1ece71446bed25fa0cf6745c19c3d5', value: web3.toWei(1, "ether")}) the to is provided by Truffle, which is of course the contract's address. ...


4

You would require ABI and the address at which the contract has been deployed. var abi = <ABI of contract>; // Set contract ABI var newContract = web3.eth.contract(abi); // Contract object var contractInstance = newContract.at(<Contract Address>); // instance of the contract contractInstance....


4

I believe what you are looking for is instance.address


4

const contract = require('truffle-contract'); const TokenArtifact = require('./../../build/contracts/YourToken.json'); var Token = contract(TokenArtifact); Token.setProvider(window.web3.currentProvider); var tokenInstance = await Token.deployed(); Now, tokenInstance.address Will give you, your deployed contract's address.


4

Some tips: have to do this asynchronously. Truffle makes the function thenable. don't need "call" explicitly because the get() is marked constant. once you have the BigNumber, then you can convert to something useful. Remember that JavaScript can't deal with 256-bit integers, so if you need to add/substract etc., always use the BigNumber library and the ...


4

This is not really an Ethereum question.. See https://stackoverflow.com/questions/750486/javascript-closure-inside-loops-simple-practical-example For your concrete case, you could do this: for(var i=0;i<5;i++){ contractt.deployed().then(function(instance){ var instancee = instance; return instancee.add(Math.random(), {from:wallet,...


4

I couldn't find where the address was stored because the JSON file I took was an out-dated version. It was one that was generated before I migrated on Truffle. It turns out that the JSON file is updated every time Truffle runs its migrations. And with that, it will add the address of the deployed contract instance. I had to dig deep into their docs to find ...


3

This function adds the given library to the links property of the destination contract. This ensures that the location of the deployed library can be found when the contract's bytecode is generated. It also merges all of the library's events in with the destination contract. API docs here: https://github.com/trufflesuite/truffle-contract#...


3

This worked for me. Hope my answer helps future readers. You have to the set the defaultAccount to be used: web3.eth.defaultAccount = web3.eth.accounts[0]; before using web3 instance. Also, In my case where I'm using react-truffle box, the invalid address can be solved by adding. this.state.web3.eth.defaultAccount = this.state.web3.eth.accounts[0]; ...


3

Truffle 3.x? Try waiting for returned promises ... truffle(development)> var meta; truffle(development)> var balance; truffle(development)> MetaCoin.deployed().then(function(instance) { meta = instance; }); truffle(development)> meta.balance().then(function(bal) { balance = bal; }); truffle(development)> balance; [big num ... ] truffle(...


3

This is the way its supposed to work. When interacting with contracts we use callback functions to wait for the response to our request and then give us the ability to do something with that response. In your example TestCase1 is run, which makes a request to create the Testing1 contract. Creating Testing1 will take an indeterminate amount of time and so ...


3

In your contract, variable owner is not public so HS.owner will be undefined. To overcome this issue, you can either declare the owner variable as public or create a getter function to get the owner like below: address public owner; or function getOwner() returns (address owner) { return owner; } As per my understanding, this should be constant ...


3

Well, after a lot of digging and hacking, I found my answer. It turns out that with truffle-contract you must provide addresses with each transaction call. So the above fails because there's no from address specified. An example solution would be something like: MyContract.new({from: 0x123...}).then(...); Or by setting the defaults for MyContract, like ...


3

The truffle-contract library doesn't need the web3 instance right away. It only needs it to be there when you start trying to use it. var contract = require("truffle-contract"); var my_contract_json = require('../../../truffle/build/contracts/MyContract.json'); var MyContract; var my_contract_deployed; window.onload = function() { if (typeof web3 !== '...


3

You are confusing "call" and "sendTransaction". When you use "call", you get the return value and you did when executing contractInstance.listAuctions.call().then(function(v) {... And your code here is not using "call" contractInstance.startAuction(auctionname, duration, { from: buyerAddress }).then(function(result) {... It is a common question as you see ...


3

I don't know if there is a real answer for that, but I use this solution: I change the migration file and I write the ABI and its address after the deploy var fs = require('fs'); var MyContract = artifacts.require('./MyContract.sol'); var fileContent = require('../build/contracts/MyContract.json'); module.exports = function(deployer) { deployer.deploy(...


Only top voted, non community-wiki answers of a minimum length are eligible