Eoslime
  • Introduction
  • Examples
  • Tutorial
  • Changelog
    • Version 2.0.0 [TypeScript]
    • Version 1.0.4
    • Version 1.0.3
    • Version 1.0.2
    • Version 1.0.1
  • Developer Documentation
    • Initialization
    • Account
      • Methods
      • Static Methods
      • Default Account
    • Multisignature Account
      • Methods
    • Providers
    • Contract
      • Deployment
      • Instantiation
      • Blockchain Contract Action Methods
    • Utils
  • CLI
    • init
      • --with-example
    • compile
      • --path
    • deploy
      • --path
      • --network
      • --deployer
    • test
      • --path
      • --network
      • --resource-report
    • shape
      • --framework
    • nodeos
      • start
        • --path
      • stop
      • logs
        • --lines
      • accounts
Powered by GitBook
On this page
  • Types of contract access
  • fromFile(abi/abiPath, contractName, ?executor)
  • at(contractName, ?executor)
  • Events
  • init

Was this helpful?

  1. Developer Documentation
  2. Contract

Instantiation

Types of contract access

There are 2 types of contract access

  • Write - Instantiate a contract with a signer/executor. You can broadcast transactions and read contract's tables

  • Read only - Instantiate a contract without a signer/executor. You can only read the contract's tables

In the case of local development a default signer/executor is set to eosio account for you

In the case of non-local development, default signer is undefined

fromFile(abi/abiPath, contractName, ?executor)

You can provide the ABI in two ways

  • The whole ABI

  • The ABI path

Defaults/Optionals:

  • executor - Default account

// Local network initialization
const eoslime = require('eoslime').init();

const CONTRACT_NAME = 'mycontract';
// Pre-created local network account
const CONTRACT_EXECUTOR = eoslime.Account.load('myaccount', 'privateKey');
const ABI_PATH = './contract/contract.abi';

const contract = eoslime.Contract.fromFile(ABI_PATH, CONTRACT_NAME, CONTRACT_EXECUTOR);

If you don't provide CONTRACT_EXECUTORthe provider default account will be applied as executor

at(contractName, ?executor)

This function is useful when you want to read the ABI from the blockchain instead of providing it as a path

Defaults/Optionals:

  • executor - Default account

// Local network initialization
const eoslime = require('eoslime').init();

const CONTRACT_NAME = 'mycontract';
// Pre-created local network account
const CONTRACT_EXECUTOR = eoslime.Account.load('myaccount', 'privateKey');

const contract = await eoslime.Contract.at(CONTRACT_NAME, CONTRACT_EXECUTOR);

If you don't provide CONTRACT_EXECUTORthe provider default account will be applied as executor

Events

init

You can process some logic every time a new contract is instantiated.

eoslime.Contract.on('init', (contract) => 
        {                
                // do some custom logic
        }
);
    

PreviousDeploymentNextBlockchain Contract Action Methods

Last updated 4 years ago

Was this helpful?