public static Amount GetERC20Balance(Address address, ERC20Token token, Revision revision) { var contractAddr = token.ContractAddress; var currRevision = revision ?? Revision.BEST; var abiDefinition = ERC20Contract.DefaultERC20Contract.FindAbiDefinition("balanceOf"); var call = AbstractContract.BuildCall(abiDefinition, address.ToHexString(null)); var contractCallResult = CallContract(call, contractAddr, currRevision); return(contractCallResult?.GetBalance(token)); }
/// <summary> /// Get current sponsor from target address. </summary> /// <param name="target"> <seealso cref="Address"/> </param> /// <param name="revision"> <seealso cref="Revision"/> </param> /// <returns> <seealso cref="ContractCallResult"/> /// throw ClientIOException network error. </returns> public static ContractCallResult GetCurrentSponsor(Address target, Revision revision) { if (target == null) { throw ClientArgumentException.Exception("target is null"); } AbiDefinition abi = ProtoTypeContract.DefaultContract.FindAbiDefinition("currentSponsor"); ContractCall call = AbstractContract.BuildCall(abi, target.ToHexString(Prefix.ZeroLowerX)); return(CallContract(call, ProtoTypeContract.ContractAddress, revision)); }
/// <summary> /// Get a master address from target address. </summary> /// <param name="target"> required <seealso cref="Address"/> target address, means transfer to address. </param> /// <param name="revision"> optional can be null <seealso cref="Revision"/> block revision. </param> /// <returns> Contract call result <seealso cref="Revision"/> </returns> /// <exception cref="ClientIOException"> </exception> public static ContractCallResult GetMasterAddress(Address target, Revision revision) { if (target == null) { throw new ArgumentNullException(nameof(target), "target is null"); } AbiDefinition abi = ProtoTypeContract.DefaultContract.FindAbiDefinition("master"); if (abi == null) { throw new ArgumentNullException(nameof(abi), "Can not find abi master method"); } ContractCall call = AbstractContract.BuildCall(abi, target.ToHexString(Prefix.ZeroLowerX)); return(CallContract(call, ProtoTypeContract.ContractAddress, revision)); }
/// <summary> /// Get boolean value if the sponsor address sponsored the target address. </summary> /// <param name="target"> required <seealso cref="Address"/> target address. </param> /// <param name="sponsor"> required <seealso cref="Address"/> sponsor </param> /// <param name="revision"> optional <seealso cref="Revision"/> block revision </param> /// <returns> <seealso cref="ContractCallResult"/> /// throw ClientIOException network error. </returns> public static ContractCallResult IsSponsor(Address target, Address sponsor, Revision revision) { if (target == null) { throw ClientArgumentException.Exception($"{nameof(target)} is null"); } if (sponsor == null) { throw ClientArgumentException.Exception("sponsor is null"); } AbiDefinition abi = ProtoTypeContract.DefaultContract.FindAbiDefinition("isSponsor"); ContractCall call = AbstractContract.BuildCall(abi, target.ToHexString(Prefix.ZeroLowerX), sponsor.ToHexString(Prefix.ZeroLowerX)); return(CallContract(call, ProtoTypeContract.ContractAddress, revision)); }
/// <summary> /// Get user credit from target address by some block revision. </summary> /// <param name="target"> <seealso cref="Address"/> target address. </param> /// <param name="user"> <seealso cref="Address"/> user address. </param> /// <param name="revision"> <seealso cref="Revision"/> revision. </param> /// <returns> <seealso cref="ContractCallResult"/> </returns> /// <exception cref="ClientIOException"> network error. </exception> public static ContractCallResult GetUserCredit(Address target, Address user, Revision revision) { if (target == null) { throw ClientArgumentException.Exception($"{nameof(target)} address is null"); } if (user == null) { throw ClientArgumentException.Exception($"{nameof(user)} address is null"); } AbiDefinition abi = ProtoTypeContract.DefaultContract.FindAbiDefinition("userCredit"); ContractCall call = AbstractContract.BuildCall(abi, target.ToHexString(Prefix.ZeroLowerX), user.ToHexString(Prefix.ZeroLowerX)); return(CallContract(call, ProtoTypeContract.ContractAddress, revision)); }