Class: ProviderRpcClient
Table of contents
Constructors
Properties
Accessors
Methods
- createContract
- createSubscriber
- hasProvider
- ensureInitialized
- requestPermissions
- changeAccount
- disconnect
- subscribe
- getProviderState
- getBalance
- getFullContractState
- getAccountsByCodeHash
- getExpectedAddress
- getStateInit
- unpackInitData
- packIntoCell
- unpackFromCell
- extractPublicKey
- codeToTvc
- mergeTvc
- splitTvc
- setCodeSalt
- getCodeSalt
- addAsset
- getTransactions
- getTransaction
- sendMessage
- sendMessageDelayed
- getBocHash
- verifySignature
- signData
- signDataRaw
- encryptData
- decryptData
Constructors
constructor
• new ProviderRpcClient(properties?)
Parameters
| Name | Type |
|---|---|
properties | ProviderProperties |
Defined in
Properties
Contract
• Contract: <Abi>(abi: Abi, address: Address) => Contract<Abi>
Type declaration
• new Contract<Abi>(abi, address)
Type parameters
| Name |
|---|
Abi |
Parameters
| Name | Type |
|---|---|
abi | Abi |
address | Address |
Defined in
Subscriber
• Subscriber: () => Subscriber
Type declaration
• new Subscriber()
Defined in
Accessors
isInitialized
• get isInitialized(): boolean
Whether provider api is ready
Returns
boolean
Defined in
raw
• get raw(): Provider
Raw provider
Returns
Defined in
rawApi
• get rawApi(): RawProviderApiMethods
Raw provider api
Returns
Defined in
Methods
createContract
▸ createContract<Abi>(abi, address): Contract<Abi>
Creates typed contract wrapper.
Deprecated
new ever.Contract(abi, address) should be used instead
Sub Category
Factory methods
Type parameters
| Name |
|---|
Abi |
Parameters
| Name | Type | Description |
|---|---|---|
abi | Abi | Readonly object (must be declared with as const) |
address | Address | Default contract address |
Returns
Contract<Abi>
Defined in
createSubscriber
▸ createSubscriber(): Subscriber
Creates subscriptions group
Deprecated
new ever.Subscriber() should be used instead
Returns
Defined in
hasProvider
▸ hasProvider(): Promise<boolean>
Checks whether this page has injected Everscale provider or there is a fallback provider.
Sub Category
Initialization and provider related methods
Returns
Promise<boolean>
Defined in
ensureInitialized
▸ ensureInitialized(): Promise<void>
Waits until provider api will be available. Calls fallback if no provider was found
Throws
ProviderNotFoundException when no provider found
Returns
Promise<void>
Defined in
requestPermissions
▸ requestPermissions(args): Promise<Partial<Permissions<Address>>>
Requests new permissions for current origin. Shows an approval window to the user. Will overwrite already existing permissions
Required permissions: none
Sub Category
Account and Permissions management
Parameters
| Name | Type |
|---|---|
args | Object |
args.permissions | keyof Permissions<Address>[] |
Returns
Promise<Partial<Permissions<Address>>>
Defined in
changeAccount
▸ changeAccount(): Promise<void>
Updates accountInteraction permission value
Requires permissions: accountInteraction
Returns
Promise<void>
Defined in
disconnect
▸ disconnect(): Promise<void>
Removes all permissions for current origin and stops all subscriptions
Returns
Promise<void>
Defined in
subscribe
▸ subscribe(eventName, params): Promise<Subscription<"contractStateChanged">>
Called every time contract state changes
Sub Category
Subscription management
Parameters
| Name | Type |
|---|---|
eventName | "contractStateChanged" |
params | Object |
params.address | Address |
Returns
Promise<Subscription<"contractStateChanged">>
Defined in
▸ subscribe(eventName, params): Promise<Subscription<"transactionsFound">>
Called on each new transactions batch, received on subscription
Parameters
| Name | Type |
|---|---|
eventName | "transactionsFound" |
params | Object |
params.address | Address |
Returns
Promise<Subscription<"transactionsFound">>
Defined in
▸ subscribe(eventName): Promise<Subscription<"connected">>
Called every time when provider connection is established
Parameters
| Name | Type |
|---|---|
eventName | "connected" |
Returns
Promise<Subscription<"connected">>
Defined in
▸ subscribe(eventName): Promise<Subscription<"disconnected">>
Called when inpage provider disconnects from extension
Parameters
| Name | Type |
|---|---|
eventName | "disconnected" |
Returns
Promise<Subscription<"disconnected">>
Defined in
▸ subscribe(eventName): Promise<Subscription<"messageStatusUpdated">>
Called every time a delayed message was delivered or expired
Parameters
| Name | Type |
|---|---|
eventName | "messageStatusUpdated" |
Returns
Promise<Subscription<"messageStatusUpdated">>
Defined in
▸ subscribe(eventName): Promise<Subscription<"networkChanged">>
Called each time the user changes network
Parameters
| Name | Type |
|---|---|
eventName | "networkChanged" |
Returns
Promise<Subscription<"networkChanged">>
Defined in
▸ subscribe(eventName): Promise<Subscription<"permissionsChanged">>
Called when permissions are changed. Mostly when account has been removed from the current accountInteraction permission, or disconnect method was called
Parameters
| Name | Type |
|---|---|
eventName | "permissionsChanged" |
Returns
Promise<Subscription<"permissionsChanged">>
Defined in
▸ subscribe(eventName): Promise<Subscription<"loggedOut">>
Called when the user logs out of the extension
Parameters
| Name | Type |
|---|---|
eventName | "loggedOut" |
Returns
Promise<Subscription<"loggedOut">>
Defined in
getProviderState
▸ getProviderState(): Promise<{ version: string ; numericVersion: number ; selectedConnection: string ; networkId: number ; supportedPermissions: keyof Permissions<Address>[] ; permissions: Partial<Permissions<Address>> ; subscriptions: { [address: string]: ContractUpdatesSubscription; } }>
Returns provider api state
Required permissions: none
Sub Category
Contract & Data Handling
Returns
Promise<{ version: string ; numericVersion: number ; selectedConnection: string ; networkId: number ; supportedPermissions: keyof Permissions<Address>[] ; permissions: Partial<Permissions<Address>> ; subscriptions: { [address: string]: ContractUpdatesSubscription; } }>
Defined in
getBalance
▸ getBalance(address): Promise<string>
Requests contract balance
Required permissions: basic
Parameters
| Name | Type |
|---|---|
address | Address |
Returns
Promise<string>
Defined in
getFullContractState
▸ getFullContractState(args): Promise<{ state: undefined | FullContractState }>
Requests contract data
Required permissions: basic
Parameters
| Name | Type | Description |
|---|---|---|
args | Object | - |
args.address | Address | Contract address |
Returns
Promise<{ state: undefined | FullContractState }>
Defined in
getAccountsByCodeHash
▸ getAccountsByCodeHash(args): Promise<{ accounts: Address[] ; continuation: undefined | string }>
Requests accounts with specified code hash
Required permissions: basic
Parameters
| Name | Type | Description |
|---|---|---|
args | Object | - |
args.codeHash | string | Hex encoded code hash |
args.continuation? | string | Last address from previous batch |
args.limit? | number | Optional limit. Values grater than 50 have no effect |
Returns
Promise<{ accounts: Address[] ; continuation: undefined | string }>
Defined in
getExpectedAddress
▸ getExpectedAddress<Abi>(abi, args): Promise<Address>
Computes contract address from code and init params
Required permissions: basic
Type parameters
| Name |
|---|
Abi |
Parameters
| Name | Type |
|---|---|
abi | Abi |
args | GetExpectedAddressParams<Abi> |
Returns
Promise<Address>
Defined in
getStateInit
▸ getStateInit<Abi>(abi, args): Promise<{ address: Address ; stateInit: string ; hash: string }>
Computes contract address and state from code and init params
Required permissions: basic
Type parameters
| Name |
|---|
Abi |
Parameters
| Name | Type |
|---|---|
abi | Abi |
args | GetExpectedAddressParams<Abi> |
Returns
Promise<{ address: Address ; stateInit: string ; hash: string }>
Defined in
unpackInitData
▸ unpackInitData<Abi>(abi, data): Promise<{ publicKey?: string ; initParams: DecodedAbiInitData<Abi> }>
Decodes initial contract data using the specified ABI
Required permissions: basic
Type parameters
| Name |
|---|
Abi |
Parameters
| Name | Type |
|---|---|
abi | Abi |
data | string |
Returns
Promise<{ publicKey?: string ; initParams: DecodedAbiInitData<Abi> }>
Defined in
packIntoCell
▸ packIntoCell<P>(args): Promise<{ boc: string ; hash: string }>
Creates base64 encoded BOC
Required permissions: basic
Type parameters
| Name | Type |
|---|---|
P | extends readonly ReadonlyAbiParam[] |
Parameters
| Name | Type |
|---|---|
args | Object |
args.abiVersion? | AbiVersion |
args.structure | P |
args.data | MergeInputObjectsArray<P> |
Returns
Promise<{ boc: string ; hash: string }>
Defined in
unpackFromCell
▸ unpackFromCell<P>(args): Promise<{ data: MergeOutputObjectsArray<P> }>
Decodes base64 encoded BOC
Required permissions: basic
Type parameters
| Name | Type |
|---|---|
P | extends readonly ReadonlyAbiParam[] |
Parameters
| Name | Type |
|---|---|
args | Object |
args.abiVersion? | AbiVersion |
args.structure | P |
args.boc | string |
args.allowPartial | boolean |
Returns
Promise<{ data: MergeOutputObjectsArray<P> }>
Defined in
extractPublicKey
▸ extractPublicKey(boc): Promise<string>
Extracts public key from raw account state
NOTE: can only be used on contracts which are deployed and has pubkey header
Required permissions: basic
Parameters
| Name | Type |
|---|---|
boc | string |
Returns
Promise<string>
Defined in
codeToTvc
▸ codeToTvc(code): Promise<string>
Converts base64 encoded contract code into tvc with default init data
Required permissions: basic
Parameters
| Name | Type |
|---|---|
code | string |
Returns
Promise<string>
Defined in
mergeTvc
▸ mergeTvc(args): Promise<{ tvc: string ; hash: string }>
Merges code and data into state init
Required permissions: basic
Parameters
| Name | Type | Description |
|---|---|---|
args | Object | - |
args.code | string | Base64 encoded contract code |
args.data | string | Base64 encoded contract data |
Returns
Promise<{ tvc: string ; hash: string }>
Defined in
splitTvc
▸ splitTvc(tvc): Promise<{ data: undefined | string ; code: undefined | string }>
Splits base64 encoded state init into code and data
Required permissions: basic
Parameters
| Name | Type |
|---|---|
tvc | string |
Returns
Promise<{ data: undefined | string ; code: undefined | string }>
Defined in
setCodeSalt
▸ setCodeSalt<P>(args): Promise<{ code: string ; hash: string }>
Merges code and data into state init
Required permissions: basic
Type parameters
| Name | Type |
|---|---|
P | extends readonly ReadonlyAbiParam[] |
Parameters
| Name | Type |
|---|---|
args | SetCodeSaltParams<P> |
Returns
Promise<{ code: string ; hash: string }>
Defined in
getCodeSalt
▸ getCodeSalt(args): Promise<undefined | string>
Retrieves salt from code. Returns undefined if code doesn't contain salt
Required permissions: basic
Parameters
| Name | Type |
|---|---|
args | GetCodeSaltParams |
Returns
Promise<undefined | string>
Defined in
addAsset
▸ addAsset<T>(args): Promise<{ newAsset: boolean }>
Adds asset to the selected account
Requires permissions: accountInteraction
Type parameters
| Name | Type |
|---|---|
T | extends "tip3_token" |
Parameters
| Name | Type |
|---|---|
args | AddAssetParams<T> |
Returns
Promise<{ newAsset: boolean }>
Defined in
getTransactions
▸ getTransactions(args): Promise<{ transactions: Transaction<Address>[] ; continuation: undefined | TransactionId ; info?: TransactionsBatchInfo }>
Requests contract transactions
Required permissions: basic
Sub Category
Transactions
Parameters
| Name | Type | Description |
|---|---|---|
args | Object | - |
args.address | Address | Contract address |
args.continuation? | TransactionId | Id of the transaction from which to request the next batch |
args.limit? | number | Optional limit. Values greater than 50 have no effect |
Returns
Promise<{ transactions: Transaction<Address>[] ; continuation: undefined | TransactionId ; info?: TransactionsBatchInfo }>
Defined in
getTransaction
▸ getTransaction(args): Promise<{ transaction: undefined | Transaction<Address> }>
Searches transaction by hash
Required permissions: basic
Parameters
| Name | Type | Description |
|---|---|---|
args | Object | - |
args.hash | string | Hex encoded transaction hash |
Returns
Promise<{ transaction: undefined | Transaction<Address> }>
Defined in
sendMessage
▸ sendMessage(args): Promise<{ transaction: Transaction<Address> }>
Sends an internal message from the user account. Shows an approval window to the user.
Required permissions: accountInteraction
Parameters
| Name | Type | Description |
|---|---|---|
args | Object | - |
args.sender | Address | Preferred wallet address. It is the same address as the accountInteraction.address, but it must be explicitly provided |
args.recipient | Address | Message destination address |
args.amount | string | Amount of nano EVER to send |
args.bounce | boolean | Whether to bounce message back on error |
args.payload? | FunctionCall<Address> | Optional function call |
args.stateInit? | string | Optional base64 encoded TVC NOTE: If the selected contract do not support this, an error is returned |
Returns
Promise<{ transaction: Transaction<Address> }>
Defined in
sendMessageDelayed
▸ sendMessageDelayed(args): Promise<DelayedMessageExecution>
Sends an internal message from the user account without waiting for the transaction. Shows an approval window to the user.
See
messageStatusUpdated
Required permissions: accountInteraction
Parameters
| Name | Type | Description |
|---|---|---|
args | Object | - |
args.sender | Address | Preferred wallet address. It is the same address as the accountInteraction.address, but it must be explicitly provided |
args.recipient | Address | Message destination address |
args.amount | string | Amount of nano EVER to send |
args.bounce | boolean | Whether to bounce message back on error |
args.payload? | FunctionCall<Address> | Optional function call |
args.stateInit? | string | Optional base64 encoded TVC NOTE: If the selected contract do not support this, an error is returned |
Returns
Promise<DelayedMessageExecution>
Defined in
getBocHash
▸ getBocHash(boc): Promise<string>
Computes hash of base64 encoded BOC
Required permissions: basic
Sub Category
Cryptography & Security
Parameters
| Name | Type |
|---|---|
boc | string |
Returns
Promise<string>
Defined in
verifySignature
▸ verifySignature(args): Promise<{ isValid: boolean }>
Parameters
| Name | Type | Description |
|---|---|---|
args | Object | - |
args.publicKey | string | The public key of the preferred account. It is the same publicKey as the accountInteraction.publicKey, but it must be explicitly provided |
args.dataHash | string | Base64 or hex encoded arbitrary bytes hash (data must be 32 bytes long) |
args.signature | string | Base64 or hex encoded signature bytes (data must be 64 bytes long) |
args.withSignatureId? | number | boolean | Whether to use the signature id during verification (true by default). - If true, uses the signature id of the selected network (if the capability is enabled). - If false, forces signature check to ignore any signature id. - If number, uses the specified number as a signature id. |
Returns
Promise<{ isValid: boolean }>
Defined in
signData
▸ signData(args): Promise<{ dataHash: string ; signature: string ; signatureHex: string ; signatureParts: { high: string ; low: string } }>
Signs arbitrary data.
NOTE: hashes data before signing. Use signDataRaw to sign without hash.
Requires permissions: accountInteraction
Parameters
| Name | Type | Description |
|---|---|---|
args | Object | - |
args.publicKey | string | The public key of the preferred account. It is the same publicKey as the accountInteraction.publicKey, but it must be explicitly provided |
args.data | string | Base64 encoded arbitrary bytes |
args.withSignatureId? | number | boolean | Whether to use the signature id for signing (true by default). - If true, uses the signature id of the selected network (if the capability is enabled). - If false, forces signature check to ignore any signature id. - If number, uses the specified number as a signature id. |
Returns
Promise<{ dataHash: string ; signature: string ; signatureHex: string ; signatureParts: { high: string ; low: string } }>
Defined in
signDataRaw
▸ signDataRaw(args): Promise<{ signature: string ; signatureHex: string ; signatureParts: { high: string ; low: string } }>
Signs arbitrary data without hashing it
Requires permissions: accountInteraction
Parameters
| Name | Type | Description |
|---|---|---|
args | Object | - |
args.publicKey | string | The public key of the preferred account. It is the same publicKey as the accountInteraction.publicKey, but it must be explicitly provided |
args.data | string | Base64 encoded arbitrary bytes |
args.withSignatureId? | number | boolean | Whether to use the signature id for signing (true by default). - If true, uses the signature id of the selected network (if the capability is enabled). - If false, forces signature check to ignore any signature id. - If number, uses the specified number as a signature id. |
Returns
Promise<{ signature: string ; signatureHex: string ; signatureParts: { high: string ; low: string } }>
Defined in
encryptData
▸ encryptData(args): Promise<EncryptedData[]>
Encrypts arbitrary data with specified algorithm for each specified recipient
Requires permissions: accountInteraction
Parameters
| Name | Type | Description |
|---|---|---|
args | Object | - |
args.publicKey | string | The public key of the preferred account. It is the same publicKey as the accountInteraction.publicKey, but it must be explicitly provided |
args.recipientPublicKeys | string[] | Public keys of recipients. Hex encoded |
args.algorithm | "ChaCha20Poly1305" | Encryption algorithm. Nonce will be generated for each recipient |
args.data | string | Base64 encoded data |
Returns
Promise<EncryptedData[]>
Defined in
decryptData
▸ decryptData(encryptedData): Promise<string>
Decrypts encrypted data. Returns base64 encoded data
Requires permissions: accountInteraction
Parameters
| Name | Type |
|---|---|
encryptedData | EncryptedData |
Returns
Promise<string>