コード例 #1
0
ファイル: TestTransaction.cs プロジェクト: arkoc/IconSDK.Net
        public void TestMessageTransactionBuilder()
        {
            var builder = new MessageTransactionBuilder();

            builder.NID        = 2;
            builder.PrivateKey = PrivateKey.Random();
            builder.To         = "hx54f7853dc6481b670caf69c5a27c7c8fe5be8269";
            builder.StepLimit  = NumericsHelper.ICX2Loop("0.1");
            builder.Value      = NumericsHelper.ICX2Loop("1");
            builder.Timestamp  = 100000000000;
            builder.Message    = "testMessage";

            var tx = builder.Build();

            Assert.True(Signer.Verify(tx.Signature, tx.Hash, tx.From));

            var hashSource = new Dictionary <string, object>()
            {
                ["version"]   = "0x3",
                ["nid"]       = "0x2",
                ["from"]      = Addresser.Create(builder.PrivateKey).ToString(),
                ["to"]        = "hx54f7853dc6481b670caf69c5a27c7c8fe5be8269",
                ["stepLimit"] = "0x16345785d8a0000",
                ["value"]     = "0xde0b6b3a7640000",
                ["timestamp"] = "0x174876e800",
                ["dataType"]  = "message",
                ["data"]      = new Bytes(Encoding.UTF8.GetBytes(builder.Message)).ToString()
            };

            var hash = Hasher.Digest(hashSource);

            Assert.AreEqual(tx.Hash, hash);
        }
コード例 #2
0
        public static void SendICX()
        {
            var wallet = WalletHelper.LoadWallet();

            Console.WriteLine();
            Console.WriteLine("How much ICX do you want to send?");
            var        amount       = BigInteger.Parse(Console.ReadLine());
            BigInteger amountToSend = amount * Consts.ICX2Loop;

            Console.WriteLine($"Enter the public address to send {amount}");
            var toAddress = Console.ReadLine();

            BigInteger stepLimit = NumericsHelper.ICX2Loop("0.000000001");
            Hash32     result    = WalletHelper.Transfer(toAddress, wallet.PrivateKey, amountToSend, stepLimit, WalletHelper.TestNetUrl);

            Console.WriteLine($"Transfer successful tx: {result}");
        }
コード例 #3
0
        private Transaction CreateTransaction(double price)
        {
            var builder = new CallTransactionBuilder
            {
                NID        = 1,
                PrivateKey = GetPrivateKey(),
                To         = _appsetting.Daedric_Address,
                StepLimit  = NumericsHelper.ICX2Loop("0.000000001"),
                Method     = "post"
            };

            //For a general purpose solution to remove scientific notation on a double to string value you need to preserve 339 places
            //https://stackoverflow.com/questions/1546113/double-to-string-conversion-without-scientific-notation
            builder.Params["value"] = price.ToString("0." + new string('#', 339));

            var tax = builder.Build();

            return(builder.Build());
        }
コード例 #4
0
ファイル: TestTransaction.cs プロジェクト: arkoc/IconSDK.Net
        public void TestCallTransactionBuilder()
        {
            var builder = new CallTransactionBuilder();

            builder.NID             = 2;
            builder.PrivateKey      = PrivateKey.Random();
            builder.To              = "cx54f7853dc6481b670caf69c5a27c7c8fe5be8269";
            builder.StepLimit       = NumericsHelper.ICX2Loop("0.10000000000");
            builder.Value           = NumericsHelper.ICX2Loop("1.00000");
            builder.Timestamp       = 100000000000;
            builder.Method          = "transfer";
            builder.Params["to"]    = new ExternalAddress("hx54f7853dc6481b670caf69c5a27c7c8fe5be8269");
            builder.Params["value"] = new BigInteger(10);

            var tx = builder.Build();

            Assert.True(Signer.Verify(tx.Signature, tx.Hash, tx.From));

            var hashSource = new Dictionary <string, object>()
            {
                ["version"]   = "0x3",
                ["nid"]       = "0x2",
                ["from"]      = Addresser.Create(builder.PrivateKey).ToString(),
                ["to"]        = "cx54f7853dc6481b670caf69c5a27c7c8fe5be8269",
                ["stepLimit"] = "0x16345785d8a0000",
                ["value"]     = "0xde0b6b3a7640000",
                ["timestamp"] = "0x174876e800",
                ["dataType"]  = "call",
                ["data"]      = new Dictionary <string, object>()
                {
                    ["method"] = "transfer",
                    ["params"] = new Dictionary <string, object>()
                    {
                        ["to"]    = "hx54f7853dc6481b670caf69c5a27c7c8fe5be8269",
                        ["value"] = "0xa"
                    }
                }
            };

            var hash = Hasher.Digest(hashSource);

            Assert.AreEqual(tx.Hash, hash);
        }
コード例 #5
0
ファイル: TestTransaction.cs プロジェクト: arkoc/IconSDK.Net
        public void TestDelopyTransaction()
        {
            var builder = new DeployTransactionBuilder();

            builder.NID             = 2;
            builder.PrivateKey      = PrivateKey.Random();
            builder.To              = "cx0000000000000000000000000000000000000000";
            builder.StepLimit       = NumericsHelper.ICX2Loop("0.1");
            builder.Timestamp       = 100000000000;
            builder.ContentType     = "application/zip";
            builder.Content         = new Bytes("0x1212121212");
            builder.Params["to"]    = new ExternalAddress("hx54f7853dc6481b670caf69c5a27c7c8fe5be8269");
            builder.Params["value"] = new BigInteger(10);

            var tx = builder.Build();

            Assert.True(Signer.Verify(tx.Signature, tx.Hash, tx.From));

            var hashSource = new Dictionary <string, object>()
            {
                ["version"]   = "0x3",
                ["nid"]       = "0x2",
                ["from"]      = Addresser.Create(builder.PrivateKey).ToString(),
                ["to"]        = "cx0000000000000000000000000000000000000000",
                ["stepLimit"] = "0x16345785d8a0000",
                ["timestamp"] = "0x174876e800",
                ["dataType"]  = "deploy",
                ["data"]      = new Dictionary <string, object>()
                {
                    ["contentType"] = "application/zip",
                    ["content"]     = "0x1212121212",
                    ["params"]      = new Dictionary <string, object>()
                    {
                        ["to"]    = "hx54f7853dc6481b670caf69c5a27c7c8fe5be8269",
                        ["value"] = "0xa"
                    }
                }
            };

            var hash = Hasher.Digest(hashSource);

            Assert.AreEqual(tx.Hash, hash);
        }