1
0
mirror of https://github.com/oceanprotocol/ocean.js.git synced 2024-11-26 20:39:05 +01:00
ocean.js/docs/classes/SmartContract.md
2023-05-02 18:18:30 +01:00

4.2 KiB

@oceanprotocol/lib / Exports / SmartContract

Class: SmartContract

Hierarchy

Table of contents

Constructors

Properties

Methods

Constructors

constructor

new SmartContract(signer, network?, config?, abi?)

Instantiate the smart contract.

Parameters

Name Type Description
signer Signer The signer object.
network? string | number Network id or name
config? Config The configuration object.
abi? AbiItem[] ABI array of the smart contract

Defined in

contracts/SmartContract.ts:25

Properties

abi

abi: AbiItem[]

Defined in

contracts/SmartContract.ts:14


config

config: Config

Defined in

contracts/SmartContract.ts:13


signer

signer: Signer

Defined in

contracts/SmartContract.ts:12

Methods

amountToUnits

Protected amountToUnits(token, amount, tokenDecimals?): Promise<string>

Converts an amount of tokens to units

Parameters

Name Type Description
token string The token to convert
amount string The amount of tokens to convert
tokenDecimals? number The number of decimals of the token

Returns

Promise<string>

  • The converted amount in units

Defined in

contracts/SmartContract.ts:43


getContract

Protected getContract(address, abi?): Contract

Returns a contract instance for the given address

Parameters

Name Type Description
address string The address of the contract
abi? AbiItem[] The ABI of the contract

Returns

Contract

  • The contract instance

Defined in

contracts/SmartContract.ts:80


getDefaultAbi

Abstract getDefaultAbi(): any

Returns

any

Defined in

contracts/SmartContract.ts:16


getFairGasPrice

Protected getFairGasPrice(): Promise<string>

Retruns the gas price

Returns

Promise<string>

  • The fair gas price

Defined in

contracts/SmartContract.ts:70


unitsToAmount

Protected unitsToAmount(token, amount, tokenDecimals?): Promise<string>

Converts an amount of units to tokens

Parameters

Name Type Description
token string The token to convert
amount string The amount of units to convert
tokenDecimals? number The number of decimals in the token

Returns

Promise<string>

  • The converted amount in tokens

Defined in

contracts/SmartContract.ts:58