cardano-web3-js / CardanoWeb3
Class: CardanoWeb3
Defined in: src/core/cw3.ts:24
CardanoWeb3 class Main class for CardanoWeb3 library which provides all the necessary functions to interact with Cardano blockchain
Constructors
Constructor
new CardanoWeb3(
config?
):CardanoWeb3
Defined in: src/core/cw3.ts:39
Initialize CardanoWeb3 library
Parameters
config?
Configuration object
Returns
CardanoWeb3
CardanoWeb3 instance
Properties
__config
__config:
object
Defined in: src/core/cw3.ts:27
network
network:
NetworkConfig
protocolParams
protocolParams:
ProtocolParameters
slotConfig
slotConfig:
SlotConfig
ttl
ttl:
number
account
account:
object
Defined in: src/core/cw3.ts:101
fromAddress()
fromAddress: (
address
) =>Account
Create a new account from address
Parameters
address
string
Bech32 address
Returns
Account instance
fromConnector()
fromConnector: (
connector
) =>Promise
<Account
>
Create new account from wallet connector
Parameters
connector
Connector instance
Returns
Promise
<Account
>
Account instance
fromMnemonic()
fromMnemonic: (
mnemonic
,password?
,accountPath
,addressPath
) =>Account
Create new account from mnemonic
Parameters
mnemonic
string
Mnemonic
password?
string
Optional password to encrypt the xprv key
accountPath?
AccountDerivationPath
= DEFAULT_ACCOUNT_DERIVATION_PATH
Account derivation path
addressPath?
AddressDerivationPath
= DEFAULT_ADDRESS_DERIVATION_PATH
Address derivation path
Returns
Account instance
fromXprvKey()
fromXprvKey: (
xprvKey
,password?
,accountPath
,addressPath
) =>Account
Create new account from xprv key
Parameters
xprvKey
string
Extended private key
password?
string
Optional password to encrypt the xprv key
accountPath?
AccountDerivationPath
= DEFAULT_ACCOUNT_DERIVATION_PATH
Account derivation path (optioanl, default: [1852, 1815, 0])
addressPath?
AddressDerivationPath
= DEFAULT_ADDRESS_DERIVATION_PATH
Address derivation path (optional, default: [0, 0])
Returns
Account instance
fromXpubKey()
fromXpubKey: (
xpubKey
,addressPath
) =>Account
Create new account from xpub key
Parameters
xpubKey
string
Extended public key
addressPath
AddressDerivationPath
= DEFAULT_ADDRESS_DERIVATION_PATH
Known Address derivation path (optional, default: [0, 0])
Returns
Account instance
importAccount()
importAccount: (
config
) =>Account
Import account from JSON config
Parameters
config
Account export config
Returns
Account instance
connector
connector:
object
Defined in: src/core/cw3.ts:72
init()
init: (
wallet
,extensions?
) =>Promise
<Connector
>
Initialize wallet connector
Parameters
wallet
string
Wallet name
extensions?
any
Wallet extensions
Returns
Promise
<Connector
>
Wallet connector instance
isEnabled()
isEnabled: (
wallet
) =>Promise
<boolean
>
Check if wallet connector is enabled
Parameters
wallet
string
Wallet name
Returns
Promise
<boolean
>
True if wallet is enabled, false otherwise
list()
list: () =>
Promise
<string
[]>
List available wallet connectors
Returns
Promise
<string
[]>
List of available connectors in window object
explorers
explorers:
Explorers
Defined in: src/core/cw3.ts:26
message
message:
object
Defined in: src/core/cw3.ts:227
signWithAccount()
signWithAccount: (
account
,message
,password?
) =>Promise
<SignedMessage
>
Sign message with account private key
Parameters
account
Account instance
message
string
Message to sign
password?
string
Password for xprv key (optional)
Returns
Promise
<SignedMessage
>
Signed message
signWithVrfKey()
signWithVrfKey: (
verificationKey
,address
,message
) =>SignedMessage
Sign message with payment key
Parameters
verificationKey
string
Payment key
address
string
Payment address
message
string
Message to sign
Returns
Signed message
verify()
verify: (
address
,message
,signedMessage
) =>boolean
Verify signed message
Parameters
address
string
Payment address
message
string
Message to verify
signedMessage
Signed message
Returns
boolean
True if message is verified, false otherwise
provider
provider:
Provider
Defined in: src/core/cw3.ts:25
Methods
createTx()
createTx():
TxBuilder
Defined in: src/core/cw3.ts:186
Generate new transaction builder
Returns
Transaction builder instance
getTip()
getTip():
Promise
<Tip
>
Defined in: src/core/cw3.ts:203
Get current tip
Returns
Promise
<Tip
>
Current tip object
importTx()
importTx(
tx
):TxFinalizer
Defined in: src/core/cw3.ts:195
Import transaction from CBOR string
Parameters
tx
string
Transaction JSON
Returns
Transaction finalizer instance
observeTx()
observeTx(
txHash
,checkInterval
,maxTime
):Promise
<boolean
>
Defined in: src/core/cw3.ts:223
Observe transaction
Parameters
txHash
string
Transaction hash
checkInterval
number
Check interval in ms
maxTime
number
Maximum time to wait in ms
Returns
Promise
<boolean
>
Transaction status (boolean)
submitTx()
submitTx(
tx
):Promise
<string
>
Defined in: src/core/cw3.ts:212
Submit transaction to blockchain
Parameters
tx
string
CBOR encoded transaction
Returns
Promise
<string
>
Transaction hash