- A lock script — the on-chain predicate that controls who can spend the cells at this address (code hash, hash type, and args).
- An address prefix —
ckbfor mainnet,cktfor testnet.
Parse an address string
UseAddress.fromString to decode an address into a structured object:
fromString validates that the address prefix matches the client’s network. It throws if there is a mismatch (e.g. passing a ckt address to a mainnet client).
You can also pass a record of clients when you need to handle both networks in the same code path:
Construct an address from a script
Build anAddress directly from a known lock script and a client:
fromKnownScript to derive an address from one of the built-in KnownScript entries:
Get an address from a signer
The most common way to obtain an address in a dApp is to ask the connected signer:Convert an address back to a string
CalltoString() on any Address instance to produce the bech32m string:
Address prefix and network
The prefix tells you which network an address belongs to:
The
Client exposes addressPrefix so you can read it at runtime: