java.lang.Object
tech.deplant.java4ever.framework.contract.OwnedContract
- Direct Known Subclasses:
EverOSGiver
,Msig
,Tip32Root
,Tip32Wallet
Class that represends deployed contract in one of the networks. It holds info about
network (sdk), address and abi of contract. If you own this contract, initialize it
with correct credentials. If it's foreign contract, use Credentials.NONE.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final record
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final ContractAbi
protected final String
protected final Credentials
protected final Sdk
-
Constructor Summary
ConstructorsConstructorDescriptionOwnedContract
(Sdk sdk, String address, ContractAbi abi) OwnedContract
(Sdk sdk, String address, ContractAbi abi, Credentials credentials) -
Method Summary
Modifier and TypeMethodDescriptionabi()
account()
Downloads actual account info, including boc.address()
balance()
Check actual EVER balance on contract's account.callExternal
(Integer functionId, Map<String, Object> functionInputs, tech.deplant.java4ever.binding.Abi.FunctionHeader functionHeader) callExternal
(Integer functionId, Map<String, Object> functionInputs, tech.deplant.java4ever.binding.Abi.FunctionHeader functionHeader, Credentials credentials) callExternal
(String functionName, Map<String, Object> functionInputs, tech.deplant.java4ever.binding.Abi.FunctionHeader functionHeader) Calls smart contract with external message using credentials provided on OwnedContract initialization.callExternal
(String functionName, Map<String, Object> functionInputs, tech.deplant.java4ever.binding.Abi.FunctionHeader functionHeader, Credentials credentials) Calls smart contract with external message.callExternalDebugTree
(String functionName, Map<String, Object> functionInputs, tech.deplant.java4ever.binding.Abi.FunctionHeader functionHeader, Credentials credentials, boolean debugThrowOnTreeErrors, List<ContractAbi> debugAbisForDecode) As with callExternal(), this method send ext message to Everscale but callExternalDebugTree() also queries message tree with "net.query_transaction_tree" returns a set of messages and transactions, logs everything and throws exceptions on errors encountered in a tree.Credentials that were provided in object constructor.encodeInternalPayload
(String functionName, Map<String, Object> functionInputs, tech.deplant.java4ever.binding.Abi.FunctionHeader functionHeader) Encodes internal message string.runGetter
(Integer functionId, Map<String, Object> functionInputs, tech.deplant.java4ever.binding.Abi.FunctionHeader functionHeader) runGetter
(Integer functionId, Map<String, Object> functionInputs, tech.deplant.java4ever.binding.Abi.FunctionHeader functionHeader, Credentials credentials) runGetter
(String functionName, Map<String, Object> functionInputs, tech.deplant.java4ever.binding.Abi.FunctionHeader functionHeader) Encodes inputs and run getter method on account's boc then decodes answer using credentials provided at OwnedContract initialization.runGetter
(String functionName, Map<String, Object> functionInputs, tech.deplant.java4ever.binding.Abi.FunctionHeader functionHeader, Credentials credentials) Encodes inputs and run getter method on account's boc then decodes answer.sdk()
Returns actual tvm.pubkey() of smart contract.
-
Field Details
-
sdk
-
address
-
abi
-
credentials
-
-
Constructor Details
-
OwnedContract
-
OwnedContract
-
-
Method Details
-
sdk
-
address
-
abi
-
balance
Check actual EVER balance on contract's account.- Returns:
- Throws:
tech.deplant.java4ever.binding.EverSdkException
-
account
Downloads actual account info, including boc. Use account().boc() to get it.- Returns:
- Throws:
tech.deplant.java4ever.binding.EverSdkException
-
credentials
Credentials that were provided in object constructor. They can be different from real pubkey inside contract's inside contract's initialData. To check real pubkey in account, use tvmPubkey() method.- Returns:
-
tvmPubkey
Returns actual tvm.pubkey() of smart contract. If you want to get Credentials specified at OwnedContract constructor - use credentials() method.- Returns:
- Throws:
tech.deplant.java4ever.binding.EverSdkException
-
encodeInternalPayload
public String encodeInternalPayload(String functionName, Map<String, Object> functionInputs, tech.deplant.java4ever.binding.Abi.FunctionHeader functionHeader) throws tech.deplant.java4ever.binding.EverSdkExceptionEncodes internal message string. Result of this method can be used as a payload for internal transactions to pass function calls and inputs with transfer.- Parameters:
functionName
-functionInputs
-functionHeader
-- Returns:
- Throws:
tech.deplant.java4ever.binding.EverSdkException
-
runGetter
public Map<String,Object> runGetter(String functionName, Map<String, Object> functionInputs, tech.deplant.java4ever.binding.Abi.FunctionHeader functionHeader, Credentials credentials) throws tech.deplant.java4ever.binding.EverSdkExceptionEncodes inputs and run getter method on account's boc then decodes answer. Important! This method always downloads new boc before running getter on it. If you need to cache boc and run multiple getters cheaply, you need to get Account object via OwnedContract.account() method and then run Account.runGetter() method.- Parameters:
functionName
-functionInputs
-functionHeader
-credentials
-- Returns:
- Throws:
tech.deplant.java4ever.binding.EverSdkException
-
runGetter
public Map<String,Object> runGetter(String functionName, Map<String, Object> functionInputs, tech.deplant.java4ever.binding.Abi.FunctionHeader functionHeader) throws tech.deplant.java4ever.binding.EverSdkExceptionEncodes inputs and run getter method on account's boc then decodes answer using credentials provided at OwnedContract initialization. Important! This method always downloads new boc before running getter on it. If you need to cache boc and run multiple getters cheaply, you need to get Account object via OwnedContract.account() method and then run Account.runGetter() method.- Parameters:
functionName
-functionInputs
-functionHeader
-- Returns:
- Throws:
tech.deplant.java4ever.binding.EverSdkException
-
runGetter
public Map<String,Object> runGetter(Integer functionId, Map<String, Object> functionInputs, tech.deplant.java4ever.binding.Abi.FunctionHeader functionHeader, Credentials credentials) throws tech.deplant.java4ever.binding.EverSdkException- Throws:
tech.deplant.java4ever.binding.EverSdkException
-
runGetter
public Map<String,Object> runGetter(Integer functionId, Map<String, Object> functionInputs, tech.deplant.java4ever.binding.Abi.FunctionHeader functionHeader) throws tech.deplant.java4ever.binding.EverSdkException- Throws:
tech.deplant.java4ever.binding.EverSdkException
-
callExternalDebugTree
public OwnedContract.ResultOfQueryTransactionTreeAndCallOutput callExternalDebugTree(String functionName, Map<String, Object> functionInputs, tech.deplant.java4ever.binding.Abi.FunctionHeader functionHeader, Credentials credentials, boolean debugThrowOnTreeErrors, List<ContractAbi> debugAbisForDecode) throws tech.deplant.java4ever.binding.EverSdkExceptionAs with callExternal(), this method send ext message to Everscale but callExternalDebugTree() also queries message tree with "net.query_transaction_tree" returns a set of messages and transactions, logs everything and throws exceptions on errors encountered in a tree.- Parameters:
functionName
-functionInputs
-functionHeader
-credentials
-debugThrowOnTreeErrors
- If 'true' method will throw on any internal non-0 exit_code encountered in tree.debugAbisForDecode
- Method will try to decode each message against ABIs in this list. ABI of entering contract already included.- Returns:
- Throws:
tech.deplant.java4ever.binding.EverSdkException
-
callExternal
public Map<String,Object> callExternal(String functionName, Map<String, Object> functionInputs, tech.deplant.java4ever.binding.Abi.FunctionHeader functionHeader, Credentials credentials) throws tech.deplant.java4ever.binding.EverSdkExceptionCalls smart contract with external message.- Parameters:
functionName
-functionInputs
-functionHeader
-credentials
-- Returns:
- Throws:
tech.deplant.java4ever.binding.EverSdkException
-
callExternal
public Map<String,Object> callExternal(String functionName, Map<String, Object> functionInputs, tech.deplant.java4ever.binding.Abi.FunctionHeader functionHeader) throws tech.deplant.java4ever.binding.EverSdkExceptionCalls smart contract with external message using credentials provided on OwnedContract initialization.- Parameters:
functionName
-functionInputs
-functionHeader
-- Returns:
- Throws:
tech.deplant.java4ever.binding.EverSdkException
-
callExternal
public Map<String,Object> callExternal(Integer functionId, Map<String, Object> functionInputs, tech.deplant.java4ever.binding.Abi.FunctionHeader functionHeader, Credentials credentials) throws tech.deplant.java4ever.binding.EverSdkException- Throws:
tech.deplant.java4ever.binding.EverSdkException
-
callExternal
public Map<String,Object> callExternal(Integer functionId, Map<String, Object> functionInputs, tech.deplant.java4ever.binding.Abi.FunctionHeader functionHeader) throws tech.deplant.java4ever.binding.EverSdkException- Throws:
tech.deplant.java4ever.binding.EverSdkException
-