Class OwnedContract

java.lang.Object
tech.deplant.java4ever.framework.contract.OwnedContract
Direct Known Subclasses:
EverOSGiver, Msig, Tip32Root, Tip32Wallet

public class OwnedContract extends Object
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.
  • Field Details

    • sdk

      protected final Sdk sdk
    • address

      protected final String address
    • abi

      protected final ContractAbi abi
    • credentials

      protected final Credentials credentials
  • Constructor Details

  • Method Details

    • sdk

      public Sdk sdk()
    • address

      public String address()
    • abi

      public ContractAbi abi()
    • balance

      public BigInteger balance() throws tech.deplant.java4ever.binding.EverSdkException
      Check actual EVER balance on contract's account.
      Returns:
      Throws:
      tech.deplant.java4ever.binding.EverSdkException
    • account

      public Account account() throws tech.deplant.java4ever.binding.EverSdkException
      Downloads actual account info, including boc. Use account().boc() to get it.
      Returns:
      Throws:
      tech.deplant.java4ever.binding.EverSdkException
    • credentials

      public Credentials 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

      public String tvmPubkey() throws tech.deplant.java4ever.binding.EverSdkException
      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.EverSdkException
      Encodes 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.EverSdkException
      Encodes 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.EverSdkException
      Encodes 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.EverSdkException
      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.
      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.EverSdkException
      Calls 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.EverSdkException
      Calls 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