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
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" --...
31
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 ...
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.
28
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 = ...
24
votes
Accepted
Truffle migrate vs Truffle deploy
truffle deploy is an alias for truffle migrate. They both do the same thing.
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 ...
19
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 ...
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 ...
13
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() ...
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)...
12
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-...
11
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 ...
11
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 ...
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 ...
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),
...
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 ...
8
votes
Truffle Flattener creates empty flat file
Try to use output parameter:
truffle-flattener .\contracts\WetherCrowdsale.sol --output WetherCrowdsale_flat.sol
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 ...
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 (...
8
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 ...
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);
...
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,
...
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 ...
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": {
...
6
votes
Prevent 'truffle test' from invoking 'truffle deploy (migrate)'
It is really embarrassing, how narrow minded the truffle authors think. My tests run their own deployment that is used in the tests. In my case, the truffle migration includes the steps that data is ...
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
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 {
...
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
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 ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
truffle-migration × 478truffle × 336
solidity × 130
truffle-deployment × 84
contract-deployment × 71
truffle-contract × 55
ganache × 33
go-ethereum × 32
ropsten × 26
truffle-compile × 25
truffle-test × 21
contract-development × 19
web3js × 18
migration × 17
infura × 16
private-blockchain × 14
testrpc × 13
javascript × 11
testing × 10
rinkeby × 10
dapps × 9
dapp-development × 9
quorum × 8
ganache-cli × 8
openethereum × 8