39 votes

What caused this error: Attempting to run transaction which calls a contract function, but recipient address is not a contract address

i´ve just used migrate --reset (without deleting /build) , and worked
user avatar
32 votes
Accepted

Steps to deploy a contract using MetaMask and Truffle

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" --...
user avatar
31 votes
Accepted

What caused this error: Attempting to run transaction which calls a contract function, but recipient address is not a contract address

As provided in comments by Mavlarn and ivicaa above, the answer is to delete the .json files under build/contracts/. Then the next run of truffle migrate no longer fails.
user avatar
28 votes
Accepted

truffle migrate: How to deploy a contract whose constructor takes a parameter

You can add the constructor parameters as extra arguments to the deploy() call const BaconMaker = artifacts.require('./BaconMaker.sol') module.exports = (deployer, network, accounts) => { const ...
user avatar
  • 29.5k
26 votes
Accepted

Truffle migrate fails

This seems to occur if you're trying to deploy contract A that depends on contract B before contract B has actually finished deploying. You probably have something like this: module.exports = ...
user avatar
  • 1,142
23 votes

Truffle: Error: Could not find a compiler version matching 0.5.0

It's solved by running with elevated permissions once: sudo truffle compile - that will download the compiler and then you can continue using non-elevated command truffle compile. That is most ...
user avatar
  • 1,067
22 votes
Accepted

Truffle migrate vs Truffle deploy

truffle deploy is an alias for truffle migrate. They both do the same thing.
user avatar
  • 16.4k
18 votes
Accepted

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

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 ...
user avatar
16 votes
Accepted

Defining constructors as functions with the same name as the contract is deprecated. Use "constructor(...) { ... }" instead

This is because of a deprecated standard. In the file, Migrations.sol, replace the line: function Migrations() public { with: constructor() public { The line of code shown just above is a ...
user avatar
12 votes
Accepted

Return Token Contract address on truffle deploy

The address of the contract is just the variable name of the deployed contract. Try this: deployer.deploy(CrowdTestToken).then(function(){ return deployer.deploy(CrowdSale, CrowdTestToken.address)...
user avatar
12 votes
Accepted

Truffle Deployment Error: Invalid number of parameters for "undefined". Got 1 expected 0!

You are passing 1 argument in an attempt to deploy an instance of contract KJToken: deployer.deploy(KJToken, KJToken.address) But the constructor of this contract takes 0 arguments: constructor() ...
user avatar
11 votes
Accepted

truffle migrate specific file

Use the flag -f for the first migration and --to for the last migration like this: truffle migrate -f 2 --to 2 Source: https://github.com/trufflesuite/truffle-migrate/issues/23#issuecomment-...
user avatar
  • 325
10 votes
Accepted

Truffle migration: Error: authentication needed: password or unlock

Ok, finally I added some code to unlock account on the fly. I do not want to store password in truffle.js (but it is possible), so doing next things: Changed 1_initial_migration.js this way: const ...
user avatar
  • 1,254
10 votes
Accepted

what is the role of Migrations.sol contract in truffle project?

The Migrations contract keeps track of which migrations were done on the current network. Inside the migrations folder, you'll see a file called 1_initial_migration.js The 1 in the filename is the ...
user avatar
  • 3,966
9 votes

Truffle post-deployment actions

With help of Karthikeyan Thangavel and Truffle docs I finally made it works: module.exports = async function(deployer) { let aInst, bInst; await Promise.all([ deployer.deploy(A), ...
user avatar
  • 1,254
9 votes
Accepted

Truffle migrate: store deployed contract address in variable

One way to achieve this through the Truffle Migration files would be to modify contract Two such that its constructor takes an address as input and stores it as oneAdd, then deploy the contracts with ...
user avatar
  • 1,190
9 votes

Prevent 'truffle test' from invoking 'truffle deploy (migrate)'

I ran into this issue as well, and it is indeed the intended behavior of truffle test: cleanroom behavior. Each run of truffle test redeploys the contracts. If it didn't, then saved state from a prior ...
user avatar
  • 301
8 votes

Truffle Flattener creates empty flat file

Try to use output parameter: truffle-flattener .\contracts\WetherCrowdsale.sol --output WetherCrowdsale_flat.sol
user avatar
  • 1,712
8 votes
Accepted

Truffle v5 runs out of gas but Truffle v4 deploys the contract

Check @goodvibration answer. It should work in most instances. I don't recommend the answer that I will share below, it will ignore the EIP-170, hopefully there is a better answer I was only able to ...
user avatar
  • 141
8 votes
Accepted

Solidity. Truffle. Call contract function in migration file

You can get a instance of deployed contract with await Ownable.deployed() after deployment. You can achieve what you are looking for with a much simpler looking script. module.exports = async (...
user avatar
7 votes

Truffle migrate fails

I prefer this syntax: module.exports = function(deployer, network, accounts) { deployer.then(async () => { await deployer.deploy(A); await deployer.deploy(B, A.address); ...
user avatar
7 votes
Accepted

Deploying contracts in Ropsten with Truffle

When I was deploying my contract through truffle in rinkeby network I too got the same error after adding from address and gas it got deployed. Try this networks: { ropsten: { network_id: 3, ...
user avatar
  • 216
7 votes

what is the role of Migrations.sol contract in truffle project?

Good Answer from here: The Migrations contract stores (in last_completed_migration) a number that corresponds to the last applied "migration" script, found in the migrations folder. Deploying this ...
user avatar
  • 3,282
7 votes

Timeout error on deploying to Rinkeby from truffle migrate

I have fixed this problem by setting networkCheckTimeout as 10000 before setting provider in truffle-config.js. networks: { bsctest: { networkCheckTimeout: 10000, provider: () => new ...
user avatar
6 votes

How does Truffle know the address of contracts published via truffle migrate?

Good qus. As far as I know. Truffle will store your contract address in build/contacts/[CONTRACT.json] file Truffle will map contract address under network json object with index. "networks": { ...
user avatar
6 votes

How to fix "No events were emitted"

If you arrived here looking for a way to print the events emitted during your tests, you can do this with the --show-events flag: truffle test --show-events
user avatar
6 votes
Accepted

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

Prior to Solidity v0.4.21: contract ContractName { function ContractName(...) public { ... } ... } Solidity v0.4.21 onward: contract ContractName { constructor(...) public { ...
user avatar
5 votes
Accepted

Issue in truffle migration with Quorum

inside module.exports, add Gas and gasPrice. network_id: "*", // Match any network id gasPrice: 0, gas: 4500000
user avatar
  • 1,014
5 votes

Truffle deploying without linking

Calling library functions declared as internal, such as those in SafeMath and Math above do not require the calling contract to be linked to the library contract as they will be copied into the ...
user avatar
  • 1,618
5 votes
Accepted

Conditions in truffle migration

The signature of the migration script function is: module.exports = function (deployer, network, accounts) { ... } If you want to branch depending on which network you are, you can check the ...
user avatar
  • 7,194

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