public class Contract
extends java.lang.Object
Contract class is a wrapper for the SmartContract
class defined in the .proto file. An object of Contract contains
same attributes with the SmartContract class.
This class provides mutator and accessor methods for all
attributes. Besides, functions of smart contracts are wrapped
and can be easily viewed through ContractFunction.toString()
ContractFunction,
Common.SmartContract| Modifier and Type | Class and Description |
|---|---|
static class |
Contract.Builder |
| Modifier and Type | Field and Description |
|---|---|
protected Common.SmartContract.ABI |
abi |
protected com.google.protobuf.ByteString |
bytecode |
protected long |
callValue |
protected com.google.protobuf.ByteString |
cntrAddr |
protected com.google.protobuf.ByteString |
codeHash |
protected ContractConstructor |
constructor |
protected long |
consumeUserResourcePercent |
protected java.util.List<ContractFunction> |
functions |
protected java.lang.String |
name |
protected com.google.protobuf.ByteString |
originAddr |
protected long |
originEnergyLimit |
protected com.google.protobuf.ByteString |
ownerAddr |
protected com.google.protobuf.ByteString |
trxHash |
protected int |
version |
protected ApiWrapper |
wrapper |
| Constructor and Description |
|---|
Contract(com.google.protobuf.ByteString cntrAddr,
Common.SmartContract.ABI abi,
com.google.protobuf.ByteString bytecode,
long consumeUserResourcePercent,
java.lang.String name,
long originEnergyLimit) |
Contract(Contract.Builder builder) |
Contract(Contract cntr,
java.lang.String ownerAddr,
ApiWrapper wrapper) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
abiToFunctions()
Convert abi entries to ContractFunction objects
|
protected java.util.List<java.lang.String> |
collectParams(java.util.List<Common.SmartContract.ABI.Entry.Param> params,
char flag) |
Contract.CreateSmartContract |
createSmartContract(java.util.List<Type<?>> buildParams)
create a CreateSmartContract object to get ready for deployment.
|
TransactionBuilder |
deploy() |
TransactionBuilder |
deploy(java.util.List<Type<?>> buildParams) |
static void |
loadAbiFromJson(java.lang.String abiString,
Common.SmartContract.ABI.Builder builder)
load abi from json format string
|
protected void |
loadConstructor()
load the constructor from ABI
|
void |
setAbi(java.lang.String abiString) |
Common.SmartContract |
toProto()
build a SmartContract object
|
protected ApiWrapper wrapper
protected com.google.protobuf.ByteString originAddr
protected com.google.protobuf.ByteString cntrAddr
protected Common.SmartContract.ABI abi
protected com.google.protobuf.ByteString bytecode
protected long callValue
protected long consumeUserResourcePercent
protected java.lang.String name
protected long originEnergyLimit
protected com.google.protobuf.ByteString codeHash
protected com.google.protobuf.ByteString trxHash
protected int version
protected com.google.protobuf.ByteString ownerAddr
protected java.util.List<ContractFunction> functions
protected ContractConstructor constructor
public Contract(Contract cntr, java.lang.String ownerAddr, ApiWrapper wrapper)
public Contract(com.google.protobuf.ByteString cntrAddr,
Common.SmartContract.ABI abi,
com.google.protobuf.ByteString bytecode,
long consumeUserResourcePercent,
java.lang.String name,
long originEnergyLimit)
public Contract(Contract.Builder builder)
public void setAbi(java.lang.String abiString)
throws java.lang.Exception
java.lang.Exceptionpublic Contract.CreateSmartContract createSmartContract(java.util.List<Type<?>> buildParams) throws java.lang.Exception
java.lang.Exception - if deployment duplicating / owner and origin address don't matchContractCreateException - if passes parameters but no constructor existsprotected void abiToFunctions()
Common.SmartContract.ABI.Entry,
;protected java.util.List<java.lang.String> collectParams(java.util.List<Common.SmartContract.ABI.Entry.Param> params, char flag)
public Common.SmartContract toProto()
public TransactionBuilder deploy() throws java.lang.Exception
java.lang.Exceptionpublic TransactionBuilder deploy(java.util.List<Type<?>> buildParams) throws java.lang.Exception
java.lang.Exceptionprotected void loadConstructor()
public static void loadAbiFromJson(java.lang.String abiString,
Common.SmartContract.ABI.Builder builder)
throws java.lang.Exception
abiString - abi string in json formatjava.lang.Exception - if the input is not valid JSON format or there are unknown fields in the input