mirror of
https://github.com/oceanprotocol/ocean.js.git
synced 2024-11-26 20:39:05 +01:00
4.2 KiB
4.2 KiB
@oceanprotocol/lib / Exports / SmartContract
Class: SmartContract
Hierarchy
-
SmartContract
↳
Nft
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
Properties
abi
• abi: AbiItem
[]
Defined in
config
• config: Config
Defined in
signer
• signer: Signer
Defined in
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
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
getDefaultAbi
▸ Abstract
getDefaultAbi(): any
Returns
any
Defined in
getFairGasPrice
▸ Protected
getFairGasPrice(): Promise
<string
>
Retruns the gas price
Returns
Promise
<string
>
- The fair gas price
Defined in
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