ton3-core / Address
Smart contract address
• new Address(address
, options?
)
Creates an instance of Address
Next formats can be used as constructor argument:
- Raw
- Base64
- Address
example
import { Address } from 'ton3-core'
const address = new Address('kf/8uRo6OBbQ97jCx2EIuKm8Wmt6Vb15+KsQHFLbKSMiYIny')
const rewrite = { workchain: 0, bounceable: true, testOnly: true }
new Address('-1:fcb91a3a3816d0f7b8c2c76108b8a9bc5a6b7a55bd79f8ab101c52db29232260')
new Address('-1:fcb91a3a3816d0f7b8c2c76108b8a9bc5a6b7a55bd79f8ab101c52db29232260', rewrite)
new Address('kf_8uRo6OBbQ97jCx2EIuKm8Wmt6Vb15-KsQHFLbKSMiYIny')
new Address(address)
Name | Type |
---|---|
address |
string | Address |
options? |
AddressRewriteOptions |
• get
hash(): Uint8Array
Get parsed Address hash part
example
import { Address, Utils } from 'ton3-core'
const address = new Address('-1:fcb91a3a3816d0f7b8c2c76108b8a9bc5a6b7a55bd79f8ab101c52db29232260')
const hash = address.hash // Uint8Array
console.log(Utils.Helpers.bytesToHex(hash))
// fcb91a3a3816d0f7b8c2c76108b8a9bc5a6b7a55bd79f8ab101c52db29232260
Uint8Array
• get
workchain(): number
Get parsed Address workchain
example
import { Address } from 'ton3-core'
const address = new Address('-1:fcb91a3a3816d0f7b8c2c76108b8a9bc5a6b7a55bd79f8ab101c52db29232260')
console.log(address.workchain)
// -1
number
• get
bounceable(): boolean
Get parsed Address bounceable flag
example
import { Address } from 'ton3-core'
const address = new Address('-1:fcb91a3a3816d0f7b8c2c76108b8a9bc5a6b7a55bd79f8ab101c52db29232260')
console.log(address.bounceable)
// false
boolean
• get
testOnly(): boolean
Get parsed Address testOnly flag
example
import { Address } from 'ton3-core'
const address = new Address('-1:fcb91a3a3816d0f7b8c2c76108b8a9bc5a6b7a55bd79f8ab101c52db29232260')
console.log(address.testOnly)
// false
boolean
▸ eq(address
): boolean
Compare instances of Address for hash and workchain equality
example
import { Address } from 'ton3-core'
const address1 = new Address('-1:fcb91a3a3816d0f7b8c2c76108b8a9bc5a6b7a55bd79f8ab101c52db29232260')
const address2 = new Address('kf_8uRo6OBbQ97jCx2EIuKm8Wmt6Vb15-KsQHFLbKSMiYIny')
console.log(address1.eq(address2))
// true
Name | Type | Description |
---|---|---|
address |
Address |
Instance of another Address |
boolean
▸ toString(type?
, options?
): string
Get raw or base64 representation of Address
example
import { Address } from 'ton3-core'
const raw = '-1:fcb91a3a3816d0f7b8c2c76108b8a9bc5a6b7a55bd79f8ab101c52db29232260'
const address = new Address(raw, { bounceable: true, testOnly: true })
console.log(address.toString('base64'))
// kf_8uRo6OBbQ97jCx2EIuKm8Wmt6Vb15-KsQHFLbKSMiYIny
console.log(address.toString('base64', { urlSafe: false }))
// kf/8uRo6OBbQ97jCx2EIuKm8Wmt6Vb15+KsQHFLbKSMiYIny
console.log(address.toString('raw', { workchain: 0 }))
// 0:fcb91a3a3816d0f7b8c2c76108b8a9bc5a6b7a55bd79f8ab101c52db29232260
Name | Type | Default value |
---|---|---|
type |
AddressType |
'base64' |
options? |
AddressStringifyOptions |
undefined |
string
▸ Static
isValid(address
): boolean
Name | Type |
---|---|
address |
any |
boolean
▪ Static
Readonly
NONE: any
= null
Helper method for writing null addresses to Builder
static