Skip to content

cardano-web3-js / CardanoWeb3

Class: CardanoWeb3

CardanoWeb3 class

Main class for CardanoWeb3 library which provides all the necessary functions to interact with Cardano blockchain

Constructors

new CardanoWeb3()

new CardanoWeb3(): CardanoWeb3

Returns

CardanoWeb3

Properties

CML

CML: __module

dcSpark @ Cardano Multiplatform Library

Defined in

src/core/cw3.ts:29


Constr

Constr: typeof Constr

Lucid Plutus Data Construction Lib

Defined in

src/core/cw3.ts:37


Data

Data: object

Any()

Any: () => TUnsafe<Data>

Returns

TUnsafe<Data>

Array()

Array: <T>(items, options?) => TArray<T>

Type Parameters

T extends TSchema

Parameters

items: T

options?

options.maxItems?: number

options.minItems?: number

options.uniqueItems?: boolean

Returns

TArray<T>

Boolean()

Boolean: () => TUnsafe<boolean>

Returns

TUnsafe<boolean>

Bytes()

Bytes: (options?) => TUnsafe<string>

Parameters

options?

options.enum?: string[]

options.maxLength?: number

options.minLength?: number

Returns

TUnsafe<string>

Enum()

Enum: <T>(items) => TUnion<T[]>

Type Parameters

T extends TSchema

Parameters

items: T[]

Returns

TUnion<T[]>

Integer()

Integer: (options?) => TUnsafe<bigint>

Parameters

options?

options.exclusiveMaximum?: number

options.exclusiveMinimum?: number

options.maximum?: number

options.minimum?: number

Returns

TUnsafe<bigint>

Literal()

Literal: <T>(title) => TLiteral<T>

Type Parameters

T extends TLiteralValue

Parameters

title: T

Returns

TLiteral<T>

Map()

Map: <T, U>(keys, values, options?) => TUnsafe<Map<Static<T, []>, Static<U, []>>>

Type Parameters

T extends TSchema

U extends TSchema

Parameters

keys: T

values: U

options?

options.maxItems?: number

options.minItems?: number

Returns

TUnsafe<Map<Static<T, []>, Static<U, []>>>

Nullable()

Nullable: <T>(item) => TUnsafe<Static<T, []>>

Type Parameters

T extends TSchema

Parameters

item: T

Returns

TUnsafe<Static<T, []>>

Object()

Object: <T>(properties, options?) => TObject<T>

Object applies by default a PlutusData Constr with index 0. Set 'hasConstr' to false to serialize Object as PlutusData List.

Type Parameters

T extends TProperties

Parameters

properties: T

options?

options.hasConstr?: boolean

Returns

TObject<T>

Tuple()

Tuple: <T>(items, options?) => TTuple<T>

Tuple is by default a PlutusData List. Set 'hasConstr' to true to apply a PlutusData Constr with index 0.

Type Parameters

T extends TSchema[]

Parameters

items: [...T[]]

options?

options.hasConstr?: boolean

Returns

TTuple<T>

castFrom()

castFrom: <T>(data, type) => T

Type Parameters

T = Data

Parameters

data: Data

type: T

Returns

T

castTo()

castTo: <T>(struct, type) => Data

Type Parameters

T

Parameters

struct: Exact<T>

type: T

Returns

Data

from()

from: <T>(raw, type?) => T

Convert Cbor encoded data to PlutusData

Type Parameters

T = Data

Parameters

raw: string

type?: T

Returns

T

fromJson()

fromJson: (json) => Data

Note Constr cannot be used here. Strings prefixed with '0x' are not UTF-8 encoded.

Parameters

json: any

Returns

Data

to()

to: <T>(data, type?) => string

Convert PlutusData to Cbor encoded data. Or apply a shape and convert the provided data struct to Cbor encoded data.

Type Parameters

T = Data

Parameters

data: Exact<T>

type?: T

Returns

string

toJson()

toJson: (plutusData) => any

Note Constr cannot be used here, also only bytes/integers as Json keys.

Parameters

plutusData: Data

Returns

any

void()

void: () => string

Returns

string

Defined in

src/core/cw3.ts:35


MSL

MSL: __module

Emurgo @ Message Signing Library

Defined in

src/core/cw3.ts:31


Message

Message: object

Message Signing/Verification Lib

signData()

signData: (addressHex, payload, privateKey) => SignedMessage

Parameters

addressHex: string

payload: string

privateKey: string

Returns

SignedMessage

verifyData()

verifyData: (addressHex, keyHash, payload, signedMessage) => boolean

Parameters

addressHex: string

keyHash: string

payload: string

signedMessage: SignedMessage

Returns

boolean

Defined in

src/core/cw3.ts:39


UPLC

UPLC: __module

UPLC @ Untyped Plutus Core Library

Defined in

src/core/cw3.ts:33


__config

__config: object

network

network: NetworkConfig

protocolParams

protocolParams: ProtocolParameters

slotConfig

slotConfig: SlotConfig

ttl

ttl: number

Defined in

src/core/cw3.ts:43


account

account: object

fromConnector()

fromConnector: (connector) => Promise<Account>

Parameters

connector: Connector

Connector instance

Returns

Promise<Account>

Account instance

fromMnemonic()

fromMnemonic: (mnemonic, accountPath, addressPath) => Account

Parameters

mnemonic: string

Mnemonic

accountPath: AccountDerivationPath = DEFAULT_ACCOUNT_DERIVATION_PATH

Account derivation path

addressPath: AddressDerivationPath = DEFAULT_ADDRESS_DERIVATION_PATH

Address derivation path

Returns

Account

Account instance

fromXprvKey()

fromXprvKey: (xprvKey, accountPath, addressPath) => Account

Parameters

xprvKey: string

Extended private 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

Account instance

fromXpubKey()

fromXpubKey: (xpubKey, addressPath) => Account

Parameters

xpubKey: string

Extended public key

addressPath: AddressDerivationPath = DEFAULT_ADDRESS_DERIVATION_PATH

Known Address derivation path (optional, default: [0, 0])

Returns

Account

Account instance

importAccount()

importAccount: (config) => Account

Parameters

config: AccountExportV1

Account export config

Returns

Account

Account instance

Defined in

src/core/cw3.ts:124


connector

connector: object

init()

init: (wallet, extensions?) => Promise<Connector>

Parameters

wallet: string

Wallet name

extensions?: any

Wallet extensions

Returns

Promise<Connector>

Wallet connector instance

isEnabled()

isEnabled: (wallet) => Promise<string[]>

Parameters

wallet: string

Wallet name

Returns

Promise<string[]>

True if wallet is enabled, false otherwise

list()

list: () => Promise<string[]>

Returns

Promise<string[]>

List of available connectors in window object

Defined in

src/core/cw3.ts:95


explorer

explorer: Explorer

Defined in

src/core/cw3.ts:40


provider

provider: Provider

Defined in

src/core/cw3.ts:41


utils

utils: Utils

Defined in

src/core/cw3.ts:42

Methods

createNativeScript()

createNativeScript(json): object

Generate new Natice Script for token minting

Parameters

json: NativeConfig

Native token config

Returns

object

Native token instance

policyId

policyId: string

script

script: Script

Defined in

src/core/cw3.ts:243


createTx()

createTx(): TxBuilder

Generate new transaction builder

Returns

TxBuilder

Transaction builder instance

Defined in

src/core/cw3.ts:196


importTx()

importTx(tx): TxFinalizer

Import transaction from CBOR string

Parameters

tx: string

Transaction JSON

Returns

TxFinalizer

Transaction finalizer instance

Defined in

src/core/cw3.ts:205


observeTx()

observeTx(txHash, checkInterval, maxTime): Promise<boolean>

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)

Defined in

src/core/cw3.ts:225


signMessageWithAccount()

signMessageWithAccount(account, message, password?): Promise<SignedMessage>

Sign message with account private key

Parameters

account: Account

Account instance

message: string

Message to sign

password?: string

Password for xprv key (optional)

Returns

Promise<SignedMessage>

Signed message

Defined in

src/core/cw3.ts:254


signMessageWithVrfKey()

signMessageWithVrfKey(verificationKey, address, message): SignedMessage

Sign message with payment key

Parameters

verificationKey: string

Payment key

address: string

Payment address

message: string

Message to sign

Returns

SignedMessage

Signed message

Defined in

src/core/cw3.ts:289


submitAndObserveTx()

submitAndObserveTx(tx): Promise<boolean>

Submit and observe transaction

Parameters

tx: string

CBOR encoded transaction

Returns

Promise<boolean>

Transaction status (boolean)

Defined in

src/core/cw3.ts:234


submitTx()

submitTx(tx): Promise<string>

Submit transaction to blockchain

Parameters

tx: string

CBOR encoded transaction

Returns

Promise<string>

Transaction hash

Defined in

src/core/cw3.ts:214


tip()

tip(): Promise<Tip>

Get current tip

Returns

Promise<Tip>

Current tip object

Defined in

src/core/cw3.ts:318


verifyMessage()

verifyMessage(address, message, signedMessage): boolean

Verify signed message

Parameters

address: string

Payment address

message: string

Message to verify

signedMessage: SignedMessage

Signed message

Returns

boolean

True if message is verified, false otherwise

Defined in

src/core/cw3.ts:305


init()

static init(config?): Promise<CardanoWeb3>

Initialize CardanoWeb3 library

Parameters

config?: InitConfig

Configuration object

Returns

Promise<CardanoWeb3>

CardanoWeb3 instance

Defined in

src/core/cw3.ts:55

Released under the MIT License