Esempio n. 1
0
        static async Task Main(string[] args)
        {
            var client = new CleosClient("http://localhost:8888");
            await client.QuickLaunchOneBoxAsync();

            var keys = await client.RetriveKeyPairsAsync("/home/cleos-net/wallet/eosio.token.key.txt");

            await client.CreateAccountAsync("eosio", "yuko", keys.PublicKey, keys.PublicKey);

            await client.PushActionAsync("eosio.token", "transfer", "eosio.token", "active", new object[] { "eosio.token", "yuko", "1000.0000 EOS", "" });

            var keys2 = await client.RetriveKeyPairsAsync("/home/cleos-net/wallet/eosio.token.key.txt");

            await client.ImportPrivateKeyToWalletAsync(keys2.PrivateKey, "eosio.token");

            await client.CreateAccountAsync("eosio", "counter", keys2.PublicKey, keys2.PublicKey);

            await client.PushActionAsync("eosio.token", "transfer", "eosio.token", "active", new object[] { "eosio.token", "counter", "1000.0000 EOS", "" });

            await client.CreateFolderAsync("/opt/eosio/contracts/counter");

            await client.UploadFileAsync("/opt/eosio/contracts/counter/counter.cpp", File.ReadAllBytes("counter.cpp"));

            await client.UploadFileAsync("/opt/eosio/contracts/counter/CMakeLists.txt", File.ReadAllBytes("CMakeLists.txt"));

            await client.CompileSmartContractAsync("/opt/eosio/contracts/counter");

            await client.SetContractAsync("/opt/eosio/contracts/counter/build", "counter", "pomelo");

            await client.PushActionAsync("counter", "init", "counter", "active", new object[] { });

            await client.PushActionAsync("counter", "add", "counter", "active", new object[] { "counter" });
        }
        public FavoriteTokenTests()
        {
            client = new CleosClient();
            config = JsonConvert.DeserializeObject <Config>(File.ReadAllText("config.json"));
            client.CreateWalletAsync("default", "/home/cleos-net/wallet/wallet.key").Wait();
            client.ImportPrivateKeyToWalletAsync(config.PrivateKey, "default").Wait();
            var builder = new DbContextOptionsBuilder();

            builder.UseMySql(config.MySql);
            db = new KyubeyContext(builder.Options);
        }
Esempio n. 3
0
        static async Task InitializeOneBox()
        {
            var configFileName = "config";
            var builder        = new ConfigurationBuilder()
                                 .SetBasePath(Directory.GetCurrentDirectory())
                                 .AddJsonFile($"{configFileName}.json")
                                 .AddEnvironmentVariables();
            var config = builder.Build();

            configObject = config.Get <Config>();

            var optionsBuilder = new DbContextOptionsBuilder <KyubeyContext>();

            optionsBuilder.UseMySql(config["MySQL"]);
            dbContext = new KyubeyContext(optionsBuilder.Options);

            client = new CleosClient();
            var createResult = await client.CreateWalletAsync("default", "/home/cleos-net/wallet/wallet.key");

            var privateKey = SecurityTool.Decrypt(config["EncryptText"], config["EncryptKey"]);
            //manual unlock
            //var unlockResult = await client.UnlockWalletAsync(SecurityTool.Decrypt(config["EncryptWalletKey"], config["EncryptKey"]));
            var importResult = await client.ImportPrivateKeyToWalletAsync(privateKey, "default");
        }
 public SmartContractTests()
 {
     client = new CleosClient("http://localhost:8888");
     client.QuickLaunchOneBoxAsync().Wait();
 }