Repository navigation
Expand file tree
/
Copy pathExample.cs
More file actions
45 lines (37 loc) · 1.98 KB
/
Copy pathExample.cs
File metadata and controls
45 lines (37 loc) · 1.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
using System;
using EthereumWalletApp.Core;
namespace EthereumWalletApp
{
class CliScript
{
static void Main(string[] args)
{
var client = new EthClient(new RpcUrl("http://localhost:8545"));
/* create new account */
var privateKey = "Pass@sdasdasdnbewrwndsnf";
Console.WriteLine("your private key: " + privateKey);
var addressTask = client.createAccount(privateKey);
var toAddress = addressTask.Result.ToString();
Console.WriteLine("New Account Address: " + toAddress);
var contractAddress = "0x920aad4a2fe079f82d71bfd4419a25bb5af41e90";
var coinOwnerAddress = "0xe9fa5c9b698433d9267d0d8cf640b55e4f18ce21";
var coinOwnerPrivateKey = "72c642d4552a4e782db10fdbcf8a82ee771d9e830b143b8fa28a04fb0ba2cdcc";
/* get balance of token owner */
var ownerBalanceTask = client.getAccountBalance(coinOwnerAddress,contractAddress);
var ownerBalance = ownerBalanceTask.Result.ToString();
Console.WriteLine("Balance of token creator :" + ownerBalance);
/* transfer 100 tokens */
var transactionHashTask = client.transferTokens(coinOwnerAddress, coinOwnerPrivateKey, toAddress, contractAddress,100);
var transactionHash = transactionHashTask.Result.ToString();
Console.WriteLine("Transaction hash: " + transactionHash);
/* get balance of account */
var tokenBalanceTask = client.getAccountBalance(toAddress,contractAddress);
var tokenBalance = tokenBalanceTask.Result.ToString();
Console.WriteLine("Balance is :" + tokenBalance);
/* get balance of token owner */
ownerBalanceTask = client.getAccountBalance(coinOwnerAddress,contractAddress);
ownerBalance = ownerBalanceTask.Result.ToString();
Console.WriteLine("Balance of token creator :" + ownerBalance);
}
}
}