Truffle is telling me that it costs 1 Eth to deploy. Is that seriously the cost of deploying a simple contract (this is my first Mainnet deploy)? Or is there something else going on?
mainnet: {
provider: () =>
new HDWalletProvider({
mnemonic: { phrase: process.env.MNEMONIC },
providerOrUrl: process.env.RPC_URL_1_WSS,
}),
network_id: 1, // Main's id
from: process.env.DEPLOYERS_ADDRESS,
gas: 4712388, // Gas limit used for deploys. Default is 4712388.
gasPrice: 211000000000, //Gas price in Wei
confirmations: 2, // # of confs to wait between deployments. (default: 0)
timeoutBlocks: 200, // # of blocks before a deployment times out (minimum/default: 50)
skipDryRun: false, // Skip dry run before migrations? (default: false for public nets )
},
},
pragma solidity ^0.7.4;
import "@chainlink/contracts/src/v0.6/interfaces/AggregatorV3Interface.sol";
import "@openzeppelin/contracts/math/SafeMath.sol";
contract EthMsg {
address payable public owner;
uint public messagesSentCount = 0;
uint decimals = 8;
uint scale = 10**decimals;
uint public txtPriceUSD = 1.70 * 10**8;
uint public txtPriceEth;
using SafeMath for uint;
AggregatorV3Interface internal priceFeed;
event Spend(
string textMsg,
string recipient
);
event TextMsgError(
string reason
);
constructor(address oracleAddress) {
owner = msg.sender;
priceFeed = AggregatorV3Interface(oracleAddress);
}
function sendTextMessage(
string calldata textMsg,
string calldata recipient
) external payable returns(bool) {
(uint newTxtPriceEth,,) = this.pollTxtPrices();
require(
msg.value > newTxtPriceEth,
'Please send the correct amount of ETH to make send a message'
);
emit Spend(textMsg, recipient);
messagesSentCount += 1;
return true;
}
function setTxtPrices(uint _txtPriceUSD) external ownerOnly() {
(int price,) = getLatestPrice();
uint ethPriceUSD = uint(price);
txtPriceEth = scale.mul(_txtPriceUSD).div(ethPriceUSD);
txtPriceUSD = _txtPriceUSD;
}
function pollTxtPrices() external view returns(uint, uint, uint) {
(int price,) = getLatestPrice();
uint newTxtPriceEth = scale.mul(txtPriceUSD).div(uint(price));
return (newTxtPriceEth, txtPriceUSD, decimals);
}
function totalBalance() external view returns(uint) {
return payable(address(this)).balance;
}
function withdrawFunds() external ownerOnly() {
msg.sender.transfer(this.totalBalance());
}
function destroy() external ownerOnly() {
selfdestruct(owner);
}
function getLatestPrice() public view returns (int, uint) {
(
,int price,,,
) = priceFeed.latestRoundData();
return (price, decimals);
}
function uintToWei(uint unum) private pure returns(uint p) {
return unum * (1 wei);
}
modifier ownerOnly() {
require(msg.sender == owner, 'only owner can call this');
_;
}
}
truffle migrate --network mainnet --reset
Replacing 'Migrations'
----------------------
Error: *** Deployment Failed ***
"Migrations" could not deploy due to insufficient funds
* Account: 0x16c8CF300eRa61f6d8e7S201AB7163FCc6660f1d
* Balance: 297068575000000000 wei
* Message: sender doesn't have enough funds to send tx. The upfront cost is: 994313868000000000 and the sender's account only has: 297068575000000000
* Try:
+ Using an adequately funded account
+ If you are using a local Geth node, verify that your node is synced.
Upfront cost is 994313868000000000 Wei??
That's almost 1 Eth!