22

The cost of your deployment is based on 5 things, with a 6th affecting the estimated cost of deployment: The flat fee of 32k gas. The CREATE op code, which is called during contract creation, costs a fixed 32k gas. This is of course on top of the 21k gas of a normal tx. Note: During contract creation from an EOA (non-contract address), the CREATE opcode isn'...


12

truffle deploy is an alias for truffle migrate. They both do the same thing.


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-...


7

This is based off what I learned here: https://ethereum.stackexchange.com/a/43004/27157 it("Should deploy with less than 4.7 mil gas", async () => { let someInstance = await SomeContract.new(); let receipt = await web3.eth.getTransactionReceipt(someInstance.transactionHash); assert.isBelow(receipt.gasUsed, 4700000); });


5

Contract has not been deployed to detected network (network/artifact mismatch) I see many different problems with your code, but not what you mentioned in your question. I cloned your github repo and launched the app with npm run dev. NOTE: Errors from the screenshot are not related to the original question. If you are curious these errors seem to ...


5

How to estimate gas for deploying a smart contract I'm using the Yellow Paper, Appendix G, page 25 as reference. The cost of gas to deploy your contract can be calculated like this: 21000 because all transactions pay this (Gtransaction) 32000 because is a contract creation (Gcreate) Your transaction will have input data, which will cost you in gas: 4 ...


5

You should test your deployment process on private network or test network throughly before trying mainnet. I am testing mine on Rinkeby because in Ropsten block gas limit is too low. In my experience gasPrice setting in truffle.js is effective. I have successfully deployed my contracts using the following syntax: geth_mainnet: { host: "127.0.0.1"...


5

Updated: Since Quorum v2.2.1, we now support remote signing for raw (read signed) private transactions. The API is explained in several places, but a great starting point is Quorum.js hosted here: https://github.com/jpmorganchase/quorum.js/ Original: answered Sep 10 '18 at 18:54 At the moment, Quorum does not support sending signed / raw txns that are ...


4

Does anyone how, in the truffle console, I can interact with contracts deployed through other contracts? To see the list of contracts already deployed on the Truffle Develop network, this command works: truffle(develop)> networks [--clean] Network: develop (id: 4447) Migrations: 0xfb88de099e13c3ed21f80a7a1e49f8caecf10df6 MyNewContract: ...


4

If your contract costs that much, then you must do a bunch of storage initialization. Storage, by far, costs the most to read/write. The irony of solidity is that it cost less to redo things in memory so if you have some variables you can re-initialize and recalculate, it's probably better to do so in memory each time a contract method is called.


4

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 calling contract's bytecode during compilation. Calling library functions declared as public or external will require the calling contract to be linked to the ...


4

You are right. Truffle test's deployed and new are from truffle-contract. If you look at the doc: deployed(): Create an instance of MyContract that represents the default address managed by MyContract. new(): Deploy a new version of this contract to the network, getting an instance > of MyContract that represents the newly deployed instance. ...


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(...


3

The --reset flag will force to run all your migrations scripts again. Compiling if some of the contracts have changed. You have to pay gas for the whole migration again. For ganache/testrpc it should not be an issue it is just a extra delay. But for deploying against a public network: mainnet, rinkeby, ropsten, etc. it can be really annoying to have to wait ...


3

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 make it migrate using: ganache-cli --gasLimit=0x1fffffffffffff --allowUnlimitedContractSize -e 1000000000 --allowUnlimitedContractSize: "Allows unlimited ...


3

After more than a week of google searches, scouring stack exchange, combining bits and pieces of what I found, and with my own trial and error, I finally came up with everything needed to successfully deploy a compiled smart contract ganache. It wasn't easy to figure out. I haven't seen a full solution presented anywhere in my searches, so I wanted to share ...


3

1.) You can make the function emit an event that broadcasts the new address and then check the logs of the transaction receipt. Receipt // Solidity function createNewContract(string memory name, string memory symbol, uint256 _maxSupply) public onlyOwner { etnX c = new etnX(name, symbol, _maxSupply, address(store)); emit NewContract(address(c)); } ...


2

You can deploy this contract in enother way: function sendRaw(rawTx) { var privateKey = new Buffer(key, 'hex'); var transaction = new tx(rawTx); transaction.sign(privateKey); var serializedTx = transaction.serialize().toString('hex'); web3.eth.sendRawTransaction( '0x' + serializedTx, function(err, result) { if(err) { ...


2

truffle.cmd migrate network --ropsten should be truffle.cmd migrate --network ropsten With truffle.cmd networks you can check which networks are available from your truffle.js.


2

Correct, contracts like these can't currently be deployed, although it may become possible to deploy them in future if and when miners raise the gas limit. 16M gas sounds like a very big contract; You may want to consider breaking it up into a number of smaller ones.


2

Short Answer: Both contracts are creating new instances of Whitelist. They are not sharing the same instance. To share the same instance - they both need to reference the same address of a single deployed Whitelist. By deploying both contracts you are, in fact, wasting (however small or large) gas as both contracts have redundant code. My suggestion (...


2

Before you can run any test, one has to define the starting point, the starting conditions in the smart contract. - Think about the values of the variable in the smart contracts. These conditions are defined by the deployment process. Hence, usually one would first run the deployment before testing. Also, this allows resetting the blockchain easily after ...


2

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 run could affect the results of a subsequent run, making your test suite non-deterministic. But I wanted to preserve state between runs of truffle test. The ...


2

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 copied from the old instance to the new instance of the main contract, then the old contract is destroyed. Unfortunately, here the snapshot does not help, the ...


2

I upvoted your answer because it seems like a nice template for doing it all with nothing but Web3. This is a good thing to know about but a little tedious, in my opinion. For the benefit of other readers who find this question/answer, the Truffle framework addresses this and other concerns with higher-level abstractions so we don't have to get down in the ...


2

It looks like you deployed to the development network but are running truffle console with the default network, so assume that these are different. You should deploy and use the console on the same network. truffle migrate --network development truffle console --network development As an aside, you shouldn't have to use sudo. You may want to consider ...


1

You need to deploy your DAPP's smart contracts on a test etherium blockchain first and then afterwards you can deploy your DAPP on aws. Docker Link : https://github.com/getamis/istanbul-tools More about etherium testNets: https://medium.com/coinmonks/how-to-deploy-a-smart-contract-to-ethereum-testnet-e34fa5b10dd6


1

Adding the '0x' to the bytecode worked for me, didn't need to reinstall the wallet provider.For some reason when I didn't add the '0x' to the bytecode, the I ended up using all the gas. If you check https://rinkeby.etherscan.io/ and scan for the account you used to deploy, it will clearly show how much gas has been used. before the '0x' it shows that all ...


1

The Truffle HDWallet provider is a convenient and easy to configure network connection to ethereum through infura.io (or any other compatible provider). For example the HDWallet provider add some features required by Truffle that are not available with infura like event filtering and transaction signing.


1

You can use truffle exec to do extra setup after deployment. Often you may want to run external scripts that interact with your contracts. Truffle provides an easy way to do this, bootstrapping your contracts based on your desired network and connecting to your Ethereum client automatically per your project configuration. Source Below is the example ...


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