CR4*_*G14 3 c# blockchain ethereum
我已经用尽了许多资源来尝试找到这个答案,但简单来说,如何创建钱包或将其集成Ethereum Blockchain到 C# 中?有许多技术,例如Web3.js、MyEtherWallet(也是 js),Nethereum它是 C#,但使用 Infura 作为 API 调用。还有一个服务叫blockcypher.com
如何创建一个公开的以太坊钱包,以便将资金从一个钱包转移到另一个钱包?终点是什么?
我想要做的是使用我的网络应用程序以编程方式为每个用户创建一个钱包,当他们赚取积分时,我再次希望以编程方式将资金从我的钱包转移到我的用户的钱包。
任何意见,将不胜感激
提前致谢
这是使用 Nethereum 的示例:
string password = "MYSTRONGPASS";
EthECKey key = EthECKey.GenerateKey();
byte[] privateKey = key.GetPrivateKeyAsBytes();
string address = key.GetPublicAddress();
var keyStore = new KeyStoreScryptService();
string json = keyStore.EncryptAndGenerateKeyStoreAsJson(
    password: password,
    privateKey: privateKey,
    addresss: address);
json可以存储在文件中。Mist 使用了这种文件格式。
小智 5
尝试 Nethereum,您可以使用任何 rpc 端点,而不仅仅是 Infura。这与 Web3js、MyEtherWallet、Web3j 等相同。
显然,您需要有一个像 Geth、Parity 或 Besu 这样运行的节点。
这是在 Nethereum 公共测试链上传输 Ether 的示例。
您还可以将其与 @LOST 响应结合起来,以使用 KeyStore 标准加密和解密您的私钥。
您可以在 Nethereum Playground http://playground.netreum.com/csharp/id/1003中运行此示例。
using System;
using System.Text;
using Nethereum.Hex.HexConvertors.Extensions;
using System.Threading.Tasks;
using Nethereum.Web3;
using Nethereum.Web3.Accounts;
public class Program
{
    private static async Task Main(string[] args)
    {
        //First let's create an account with our private key for the account address 
        var privateKey = "0x7580e7fb49df1c861f0050fae31c2224c6aba908e116b8da44ee8cd927b990b0";
        var account = new Account(privateKey);
        Console.WriteLine("Our account: " + account.Address);
        //Now let's create an instance of Web3 using our account pointing to our nethereum testchain
        var web3 = new Web3(account, "http://testchain.nethereum.com:8545");
        // Check the balance of the account we are going to send the Ether
        var balance = await web3.Eth.GetBalance.SendRequestAsync("0x13f022d72158410433cbd66f5dd8bf6d2d129924");
        Console.WriteLine("Receiver account balance before sending Ether: " + balance.Value + " Wei");
        Console.WriteLine("Receiver account balance before sending Ether: " + Web3.Convert.FromWei(balance.Value) +
                          " Ether");
        // Lets transfer 1.11 Ether
        var transaction = await web3.Eth.GetEtherTransferService()
            .TransferEtherAndWaitForReceiptAsync("0x13f022d72158410433cbd66f5dd8bf6d2d129924", 1.11m);
        balance = await web3.Eth.GetBalance.SendRequestAsync("0x13f022d72158410433cbd66f5dd8bf6d2d129924");
        Console.WriteLine("Receiver account balance after sending Ether: " + balance.Value);
        Console.WriteLine("Receiver account balance after sending Ether: " + Web3.Convert.FromWei(balance.Value) +
                          " Ether");
    }
}
您有许多使用 Nethereum 的以太坊钱包示例,可以在这里找到它们http://docs.nethereum.com/en/latest/nethereum-ui-wallets/
| 归档时间: | 
 | 
| 查看次数: | 5517 次 | 
| 最近记录: |