Beispiel #1
0
        public void TestCreateUserAccount()
        {
            var node                = new Node();
            var script              = @"let tokenomicaPubKey = base58'7dkSgXFv9EpYi3C3JK76wJTkciBsVPZ1xE5fVAMB6AD9'                            
                            let this = extract(tx.sender)

                            match tx { 
                                case s: SetScriptTransaction =>
                                    sigVerify(s.bodyBytes, s.proofs[0], tokenomicaPubKey)
                                case t: TransferTransaction =>
                                    let limit = extract(getInteger(tx.sender, ""limit""))
                                    (!isDefined(t.assetId) &&
                                     t.amount <= limit ||
                                    isDefined(t.assetId)) &&
                                    sigVerify(t.bodyBytes, t.proofs[0], t.senderPublicKey)
                                case m: MassTransferTransaction =>
                                    let limit = extract(getInteger(this, ""limit""))
                                    (!isDefined(m.assetId) &&
                                    m.totalAmount <= limit ||
                                    isDefined(m.assetId)) &&
                                    sigVerify(m.bodyBytes, m.proofs[0], tx.senderPublicKey)
                                case e: ExchangeTransaction =>
                                    let limit = extract(getInteger(this, ""limit""))
                                    ((!isDefined(e.sellOrder.assetPair.amountAsset) && e.buyOrder.amount <= limit)
                                        || isDefined(e.sellOrder.assetPair.amountAsset)) &&
                                    ((!isDefined(e.sellOrder.assetPair.priceAsset) && e.sellOrder.amount <= limit)
                                        || isDefined(e.buyOrder.assetPair.amountAsset)) &&
                                    sigVerify(e.bodyBytes, e.proofs[0], tx.senderPublicKey)
                                case d: DataTransaction =>
                                    sigVerify(d.bodyBytes, d.proofs[0], tokenomicaPubKey)
                                case _ => false
                            }";
            var compiledScript      = node.CompileScript(script);
            var transferTransaction = new TransferTransaction(Alice.PublicKey, userAccount.Address, Assets.WAVES, 1m, 0.001m).Sign(Alice);

            node.Broadcast(transferTransaction.GetJsonWithSignature());
            Thread.Sleep(5000);

            var setScriptTx = new SetScriptTransaction(userAccount.PublicKey, compiledScript, AddressEncoding.TestNet, 0.14m);

            setScriptTx.Sign(userAccount);
            node.Broadcast(setScriptTx.GetJsonWithSignature());
        }
Beispiel #2
0
        public void TestWavesSpendingUserAccountScript()
        {
            var node = new Node();



            var tokenomicaSeed    = "aim property attract warfare stamp sample holiday input invest rather potato novel produce car arctic"; //3N6GrCERRyWw9k9siP9iPbqNV9q86jnbrYY
            var tokenomicaAccount = PrivateKeyAccount.CreateFromSeed(tokenomicaSeed, AddressEncoding.TestNet);

            var data = new DictionaryObject
            {
                { "limit", 200000001L }
            };

            var dataTx = new DataTransaction(userAccount.PublicKey, data, 0.005m).Sign(tokenomicaAccount);

            node.Broadcast(dataTx.GetJsonWithSignature());

            var wavesTransferTx = new TransferTransaction(userAccount.PublicKey, Alice.Address, Assets.WAVES, 0.01m, 0.005m).Sign(userAccount);

            wavesTransferTx.Version = 2;
            node.Broadcast(wavesTransferTx.GetJsonWithSignature());
        }