Skip to content
This repository has been archived by the owner on Apr 6, 2020. It is now read-only.

Want to test transfer method using neo-gui-developer #54

Open
webplusai opened this issue Jul 27, 2018 · 0 comments
Open

Want to test transfer method using neo-gui-developer #54

webplusai opened this issue Jul 27, 2018 · 0 comments

Comments

@webplusai
Copy link

webplusai commented Jul 27, 2018

I want to invoke transfer method which is as following.

public static bool Transfer(StorageContext context, byte[] from, byte[] to, BigInteger amount)
{
            if (from.Length != 20 || to.Length != 20) return false;
            if (amount <= 0) return false;
            if (!Runtime.CheckWitness(from)) return false;
            if (from == to) return true;

            BigInteger fromBalance = Storage.Get(context, from).AsBigInteger();
            if (fromBalance < amount) return false;
            if (fromBalance == amount)
                Storage.Delete(context, from);
            else
                Storage.Put(context, from, fromBalance - amount);

            BigInteger toBalance = Storage.Get(context, to).AsBigInteger();
            Storage.Put(context, to, toBalance + amount);
            Transferred(from, to, amount);
            return true;
}

method invoke is not succeeded because it stops at line 5 if (!Runtime.CheckWitness(from)) return false;, which always returns false.

How can I make CheckWitness return true?
Thanks for help in advance.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant