This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apt-get update && apt-get install -y aptitude git lxc-utils zfsutils-linux netfilter-persistent sysstat | |
# find the partition ID that is linked to the storage serial number. | |
# This will prevent from losing the partition if disk mapping changes | |
ls -l /dev/disk/by-id/ | grep sda6 | |
zpool create -f zdata /dev/disk/by-id/wwn-0x600507604092b628236df4851535cef5-part6 | |
## Fixate internal IP address of the container | |
systemctl stop lxc-net | |
sed -i -e 's,^.*LXC_DHCP_CONFILE,LXC_DHCP_CONFILE,' /etc/default/lxc-net |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Test] | |
public async Task DeployContract() | |
{ | |
var deploymentMessage = new TokenDeployment { TotalSupply = 10 }; | |
var deploymentHandler = _web3.Eth.GetContractDeploymentHandler<TokenDeployment>(); | |
var transactionReceipt = await deploymentHandler.SendRequestAndWaitForReceiptAsync(deploymentMessage); | |
_contractAddress = transactionReceipt.ContractAddress; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Test] | |
public async Task GenerateAddresses() | |
{ | |
var wallet = new Wallet("carry fix final shield cruel learn pave during habit adapt alter habit", ""); | |
string[] addressList = new string[5]; | |
for (int i = 0; i < 5; i++) | |
{ | |
var account = wallet.GetAccount(i); | |
addressList[i] = account.Address; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Test] | |
public async Task GetEvents_Filtered() | |
{ | |
string contractAddress = "0xD267808D8fB2F2D6b02074DAC2F00036D5FcB3EE"; | |
var transferEventHandler = _web3.Eth.GetEvent<TransferEventDTO>(contractAddress); | |
string ownerAddress = "0x228cD92AA7E3e2B4353597ec0B767B856d03E489"; | |
string receiverAddress = "0x576077aCC546d475845a4178ECF0B467CC7D7e10"; | |
var filterAllTransferEvents = transferEventHandler.CreateFilterInput(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Test] | |
public async Task GetEvents() | |
{ | |
string contractAddress = "0xD267808D8fB2F2D6b02074DAC2F00036D5FcB3EE"; | |
var transferEventHandler = _web3.Eth.GetEvent<TransferEventDTO>(contractAddress); | |
var filterAllTransferEvents = transferEventHandler.CreateFilterInput(); | |
var allTransferEvents = await transferEventHandler.GetAllChanges(filterAllTransferEvents); | |
foreach (var transferEvent in allTransferEvents) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Event("Transfer")] | |
public class TransferEventDTO : IEventDTO | |
{ | |
[Parameter("address", "_from", 1, true)] | |
public string From { get; set; } | |
[Parameter("address", "_to", 2, true)] | |
public string To { get; set; } | |
[Parameter("uint256", "_value", 3, false)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Test] | |
public async Task Transfer() | |
{ | |
string contractAddress = "0xD267808D8fB2F2D6b02074DAC2F00036D5FcB3EE"; | |
string ownerAddress = "0x228cD92AA7E3e2B4353597ec0B767B856d03E489"; | |
string receiverAddress = "0x576077aCC546d475845a4178ECF0B467CC7D7e10"; | |
var transferHandler = _web3.Eth.GetContractTransactionHandler<TransferFunction>(); | |
var transfer = new TransferFunction() { To = receiverAddress, TokenAmount = 1 }; | |
await transferHandler.SendRequestAndWaitForReceiptAsync(contractAddress, transfer); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Function("transfer", "bool")] | |
public class TransferFunction : FunctionMessage | |
{ | |
[Parameter("address", "_to", 1)] | |
public string To { get; set; } | |
[Parameter("uint256", "_value", 2)] | |
public BigInteger TokenAmount { get; set; } | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Function("balanceOf", "uint256")] | |
public class BalanceOfFunction : FunctionMessage | |
{ | |
[Parameter("address", "_owner", 1)] | |
public string Owner { get; set; } | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Test] | |
public async Task GetBalance() | |
{ | |
string contractAddress = "0xD267808D8fB2F2D6b02074DAC2F00036D5FcB3EE"; | |
string ownerAddress = "0x228cD92AA7E3e2B4353597ec0B767B856d03E489"; | |
string receiverAddress = "0x576077aCC546d475845a4178ECF0B467CC7D7e10"; | |
var balanceHandler = _web3.Eth.GetContractQueryHandler<BalanceOfFunction>(); | |
var ownerBalance = await balanceHandler.QueryAsync<BigInteger>(contractAddress, new BalanceOfFunction() { Owner = ownerAddress }); | |
Assert.AreEqual(10, (int) ownerBalance); |