/// <summary> /// Transfer NEP5 token balance, with common data types /// </summary> /// <param name="tokenHash">nep5 token script hash, Example: scripthash ("0xb0a31817c80ad5f87b6ed390ecb3f9d312f7ceb8")</param> /// <param name="fromKey">wif or private key /// Example: WIF ("KyXwTh1hB76RRMquSvnxZrJzQx7h9nQP2PCRL38v6VDb5ip3nf1p"), PrivateKey ("450d6c2a04b5b470339a745427bae6828400cf048400837d73c415063835e005")</param> /// <param name="toAddress">address or account script hash</param> /// <param name="amount">token amount</param> /// <returns></returns> public Transaction Transfer(string tokenHash, string fromKey, string toAddress, decimal amount) { UInt160 scriptHash = Utility.GetScriptHash(tokenHash); var decimals = nep5API.Decimals(scriptHash); KeyPair from = Utility.GetKeyPair(fromKey); UInt160 to = Utility.GetScriptHash(toAddress); BigInteger amountInteger = amount.ToBigInteger(decimals); return(Transfer(scriptHash, from, to, amountInteger)); }
/// <summary> /// Transfer NEP5 token balance, with common data types /// </summary> /// <param name="tokenHash">nep5 token script hash, Example: scripthash ("0x6a38cd693b615aea24dd00de12a9f5836844da91")</param> /// <param name="fromKey">wif or private key /// Example: WIF ("KyXwTh1hB76RRMquSvnxZrJzQx7h9nQP2PCRL38v6VDb5ip3nf1p"), PrivateKey ("450d6c2a04b5b470339a745427bae6828400cf048400837d73c415063835e005")</param> /// <param name="toAddress">address or account script hash</param> /// <param name="amount">token amount</param> /// <param name="networkFee">netwotk fee, set to be 0 will auto calculate the least fee</param> /// <returns></returns> public Transaction Transfer(string tokenHash, string fromKey, string toAddress, decimal amount, decimal networkFee = 0) { UInt160 scriptHash = Utility.GetScriptHash(tokenHash); var decimals = nep5API.Decimals(scriptHash); KeyPair from = Utility.GetKeyPair(fromKey); UInt160 to = Utility.GetScriptHash(toAddress); BigInteger amountInteger = amount.ToBigInteger(decimals); BigInteger networkFeeInteger = networkFee.ToBigInteger(NativeContract.GAS.Decimals); return(Transfer(scriptHash, from, to, amountInteger, (long)networkFeeInteger)); }