When deploying with Truffle how do you specify which wallet address to deploy with? I know if you're using web3 you can specify web3.eth.defaultAccount
but how would I do this Truffle? I read somewhere to adjust your truffle.js
file and add a from
but it spits an error for me. How would truffle know which address I'm using to interact with it, e.g. me using MetaMask.
[Ethereum] How to specify which wallet address to deploy contract with
truffleweb3js
Best Answer
By default, truffle uses the first account but in
truffle.js
you can specify the account address in thefrom
property:If you want to deploy to a network other than localhost then you need to import a wallet provider and pass it your mnemonic.
Here's an example where the mnemonic is read from an environment variable and the provider is set to rinkeby testnet: