Пример #1
0
        public static ToClause BuildTranferToClause(ERC20Token token, Address toAddress, Amount amount)
        {
            if (token == null)
            {
                throw new ArgumentNullException(nameof(token), "token is null");
            }
            if (toAddress == null)
            {
                throw new ArgumentNullException(nameof(token), "toAddress is null");
            }
            if (amount == null)
            {
                throw new ArgumentNullException(nameof(amount), "amount is null");
            }

            var abiDefinition = DefaultERC20Contract.FindAbiDefinition("transfer");

            if (abiDefinition == null)
            {
                throw new System.Exception("can not find transfer abi method");
            }
            var data = BuildData(abiDefinition, toAddress.ToHexString(null), amount.ToBigInteger());

            var toData = new ToData();

            toData.SetData(data);
            return(new ToClause(token.ContractAddress, Amount.ZERO, toData));
        }
Пример #2
0
        public Amount GetBalance(ERC20Token token)
        {
            var balance = Amount.CreateFromToken(token);

            balance.SetHexAmount(Data);
            return(balance);
        }