private void btnPublish_Click(object sender, EventArgs e)
{
var accountValue = cmbAccounts.SelectedItem;
if (accountValue == null)
{
var result = MessageBoxEx.Show(this, string.Format("Select an account to publish from"), "Block Studio", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
var account = (Account) accountValue;
if (account.Balance < 10000000)
{
var result = MessageBoxEx.Show(this, string.Format("You do not have enough Ether to publish the contract"), "Block Studio", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
var bin = BlockStudioProjectService.GetFile(SolcProjectFileType.Bin);
if (bin==null)
{
var result = MessageBoxEx.Show(this, string.Format("It appears there is no bytecode generated for this project"), "Block Studio", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
var transaction = new Transaction()
{
From = account.Address,
Data = bin.Value,
Gas = txtEstimateGas.Text
};
BlockStudioProjectService.PublishedTxHash = BlockStudioProjectService.BlockStudioProject.Connection.EthereumService.SendTransaction(transaction);
_ethereumFilterManager.AddBlockPendingFilter(BlockStudioProjectService.PublishedTxHash);
_ethereumFilterManager.Start();
txtBuildOutput.WriteConsonsoleMessage("contract published with code: {0}", BlockStudioProjectService.GetFile(SolcProjectFileType.Bin).Value);
}