Exemple #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 async Task CompileAndSetContractTests()
        {
            // Arrange
            await client.PushActionAsync("eosio.token", "create", "eosio.token", "active", new[] { "eosio.token", "1000000000.0000 KBY" });

            await client.PushActionAsync("eosio.token", "issue", "eosio.token", "active", new[] { "eosio.token", "1000000000.0000 KBY", "OneBox Init" });

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

            await client.UploadFileAsync("/opt/eosio/contracts/pomelo/pomelo.hpp", File.ReadAllBytes(Path.Combine(GetProjectRootPath(), "Contract/pomelo.hpp")));

            await client.UploadFileAsync("/opt/eosio/contracts/pomelo/pomelo.cpp", File.ReadAllBytes(Path.Combine(GetProjectRootPath(), "Contract/pomelo.cpp")));

            await client.UploadFileAsync("/opt/eosio/contracts/pomelo/CMakeLists.txt", File.ReadAllBytes(Path.Combine(GetProjectRootPath(), "Contract/CMakeLists.txt")));

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

            await client.GenerateKeyValuePair("/home/cleos-net/wallet/pomelo.txt");

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

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

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

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

            var result = await client.SetContractAsync("/opt/eosio/contracts/pomelo", "pomelo", "pomelo");

            await client.PushActionAsync("pomelo", "setwhitelist", "pomelo", "active", new[] { "KBY", "eosio.token" });

            // Assert
            Assert.True(result.IsSucceeded);
        }