Client side library written in Typescript for building application utilizing Tezos crypto currency and Trezor hardware wallet.
Tezos wallet simplifies communication with Tezos nodes and significantly reduces burden of working with Tezos network.
Add NPM package to the list of dependencies
npm install tezos-wallet
Project is based on RxJS and relies on it as peer dependency, therefore add supported version as dependency of you project.
npm install rxjs@~6.3.2
Import the libary methods as import { initializeWallet, getWallet } from 'tezos-wallet';
Library is tested with Typescript versions 3.2.2.
Code is well described and documentation generated using Typedoc can be viewed in docs folder.
Code samples describing usage can be found in example folder.
- ActivateWalletOperationMetadata
- BaseOperationMetadata
- Config
- DelegationOperationMetadata
- OriginationOperationMetadata
- RevealOperationMetadata
- RpcParams
- State
- TZScanNode
- TezosNode
- TransactionOperationMetadata
- TrezorConnectResponse
- TrezorMessage
- WalletBase
- ActivatedWallet
- BalanceUpdate
- ConfirmOperation
- ContractBalanceUpdate
- ErrorKind
- FeeBalanceUpdate
- Head
- HeadConstants
- InjectionError
- InjectionOperation
- LowFeeError
- ManagerKey
- Mempool
- MempoolOperation
- OperationApplicationResult
- OperationMetadata
- OperationValidationResult
- OriginatedContract
- PackOperationParameters
- PendingOperation
- PreapplyOperation
- RpcError
- SetDelegate
- SignOperation
- StateActivateWallet
- StateConfirmOperation
- StateConstants
- StateCounter
- StateHead
- StateInjectionOperation
- StateManagerKey
- StateMempool
- StateOperation
- StateOperations
- StateOriginateContract
- StatePackOperationParameters
- StatePendingOperation
- StatePreapplyOperation
- StateSetDelegate
- StateSignOperation
- StateTransaction
- StateValidatedOperations
- StateWallet
- StateWalletDetail
- Transaction
- TrezorDelegationOperation
- TrezorOperationTarget
- TrezorOriginationOperation
- TrezorRevealOperation
- TrezorTransactionOperation
- ValidationError
- ValidationResult
- Wallet
- WalletDetail
- activateWallet
- applyAndInjectOperation
- base58CheckDecode
- bs58checkEncode
- checkPropertyWithError
- concatKeys
- confirmOperation
- constants
- counter
- forgeOperation
- forgeOperationAtomic
- getWallet
- hasAppliedOperationInMempool
- hasRefusedOperationInMempool
- head
- initializeWallet
- injectOperations
- keys
- managerKey
- newWallet
- operation
- operationIsValid
- originateContract
- packOperationParameters
- packOperationParametersAtomic
- parseAmount
- pendingOperation
- pendingOperationsAtomic
- preapplyOperations
- ready
- rpc
- setDelegation
- signOperation
- signOperationTrezor
- transaction
- updateFeesForOperation
- validateOperation
- validateOperationAtomic
- validateOriginationOperation
- validateRevealOperation
- validateTransactionOperation
Ƭ ActivatedWallet: object
Defined in common/state.ts:31
secret: string
Ƭ BalanceUpdate: * ContractBalanceUpdate | FeeBalanceUpdate *
Defined in common/operations.ts:64
Ƭ ConfirmOperation: object
Defined in common/state.ts:35
injectionOperation: InjectionOperation
Ƭ ContractBalanceUpdate: object
Defined in common/operations.ts:50
change: string
contract: string
kind: "contract"
Ƭ ErrorKind: * "temporary" | "permanent" *
Defined in common/errors.ts:4
Ƭ FeeBalanceUpdate: object
Defined in common/operations.ts:56
category: "fees"
change: string
delegate: string
kind: "freezer"
level: number
Ƭ Head: object
Defined in common/state.ts:67
chain_id: string
hash: string
header: object
context: string
fitness: [string
, string
]
level: number
operations_hash: string
predecessor: string
priority: number
proof_of_work_nonce: string
proto: number
signature: string
timestamp: string
validation_pass: number
metadata: object
baker: string
balance_updates: any
[]
consumed_gas: string
deactivated: any
[]
level: any
max_block_header_length: number
max_operation_data_length: number
max_operation_list_length: object
[]
max_operations_ttl: number
next_protocol: string
nonce_hash: string
| null
protocol: string
test_chain_status: object
status: "running" | "not_running"
voting_period_kind: "proposal"
operations: object
[]
protocol: string
Ƭ HeadConstants: object
Defined in common/state.ts:39
block_reward: string
block_security_deposit: string
blocks_per_commitment: number
blocks_per_cycle: number
blocks_per_roll_snapshot: number
blocks_per_voting_period: number
cost_per_byte: string
endorsement_reward: string
endorsement_security_deposit: string
endorsers_per_block: number
hard_gas_limit_per_block: string
hard_gas_limit_per_operation: string
hard_storage_limit_per_operation: string
max_operation_data_length: number
max_proposals_per_delegate: number
max_revelations_per_block: number
michelson_maximum_type_size: number
nonce_length: number
origination_size: number
preserved_cycles: number
proof_of_work_nonce_size: number
proof_of_work_threshold: string
seed_nonce_revelation_tip: string
time_between_blocks: string
[]
tokens_per_roll: string
Ƭ InjectionError: object
Defined in common/errors.ts:24
response: object
[]
state: S
Ƭ InjectionOperation: object
Defined in common/state.ts:119
Ƭ LowFeeError: object
Defined in common/errors.ts:33
response: object
[]
state: S
Ƭ ManagerKey: object
Defined in common/state.ts:138
key: string
manager: string
Ƭ Mempool: object
Defined in common/state.ts:130
applied: MempoolOperation[]
branch_delayed: MempoolOperation[]
branch_refused: MempoolOperation[]
refused: MempoolOperation[]
unprocessed: MempoolOperation[]
Ƭ MempoolOperation: object
Defined in common/state.ts:123
branch: string
contents: any
hash: string
signature: string
Ƭ OperationApplicationResult: * OperationValidationResult & object
*
Defined in common/operations.ts:80
Ƭ OperationMetadata: * BaseOperationMetadata & RevealOperationMetadata | TransactionOperationMetadata | OriginationOperationMetadata | DelegationOperationMetadata | ActivateWalletOperationMetadata
Defined in common/operations.ts:41
Ƭ OperationValidationResult: * OperationMetadata & object
*
Defined in common/operations.ts:66
Ƭ OriginatedContract: object
Defined in common/state.ts:143
amount: string
fee: string
Optional
testRun: undefined
| false
| true
to: string
Ƭ PackOperationParameters: object
Defined in common/state.ts:150
Ƭ PendingOperation: object
Defined in common/state.ts:154
publicKeyHash: string
Ƭ PreapplyOperation: object
Defined in common/state.ts:158
contents: OperationValidationResult[]
signature: string
Ƭ RpcError: object
Defined in common/errors.ts:6
response: object
[]
state: S
Ƭ SetDelegate: object
Defined in common/state.ts:163
fee: string
Optional
testRun: undefined
| false
| true
to: string
Ƭ SignOperation: object
Defined in common/state.ts:169
operationHash: string
signature: string
signedOperationContents: string
Ƭ StateActivateWallet: object
Defined in wallet/activateWallet.ts:9
activateWallet: ActivatedWallet
Ƭ StateConfirmOperation: object
Defined in operation/confirmOperation.ts:8
confirmOperation: object
injectionOperation: InjectionOperation
Ƭ StateConstants: object
Defined in head/getConstants.ts:6
constants: HeadConstants
Ƭ StateCounter: object
Defined in contract/getContractCounter.ts:6
counter: number
Ƭ StateHead: object
Defined in head/getHead.ts:6
head: Head
Ƭ StateInjectionOperation: object
Defined in operation/applyInjectOperation.ts:16
injectionOperation: InjectionOperation
Ƭ StateManagerKey: object
Defined in contract/getContractManagerKey.ts:6
manager_key: ManagerKey
Ƭ StateMempool: object
Defined in operation/pendingOperation.ts:6
mempool: Mempool
Ƭ StateOperation: object
Defined in operation/forgeOperation.ts:16
operation: string
Ƭ StateOperations: object
Defined in operation/operation.ts:9
operations: OperationMetadata[]
Ƭ StateOriginateContract: object
Defined in contract/originateContract.ts:14
originateContract: OriginatedContract
Ƭ StatePackOperationParameters: object
Defined in operation/packOperationData.ts:7
packOperationParameters: PackOperationParameters
Ƭ StatePendingOperation: object
Defined in operation/pendingOperation.ts:10
pendingOperation: PendingOperation
Ƭ StatePreapplyOperation: object
Defined in operation/applyInjectOperation.ts:12
preapply: PreapplyOperation
Ƭ StateSetDelegate: object
Defined in delegate/setDelegate.ts:11
setDelegate: SetDelegate
Ƭ StateSignOperation: object
Defined in operation/signOperation.ts:35
signOperation: SignOperation
Ƭ StateTransaction: object
Defined in transaction/createTransaction.ts:11
transaction: Transaction
Ƭ StateValidatedOperations: object
Defined in operation/validateOperation.ts:10
validatedOperations: ValidationResult
Ƭ StateWallet: object
Defined in wallet/initializeWallet.ts:8
wallet: Wallet
Ƭ StateWalletDetail: object
Defined in wallet/getWallet.ts:5
getWallet: WalletDetail
Ƭ Transaction: object
Defined in common/state.ts:175
amount: string
fee: string
Optional
parameters: Record
<string
, any
>
Optional
testRun: undefined
| false
| true
to: string
Ƭ TrezorDelegationOperation: object
Defined in common/operations.ts:122
counter: number
delegate: string
fee: number
gas_limit: number
source: string
storage_limit: number
Ƭ TrezorOperationTarget: object
Defined in common/operations.ts:85
hash: Uint8Array
| null
tag: number
Ƭ TrezorOriginationOperation: object
Defined in common/operations.ts:109
balance: number
counter: number
delegatable: boolean
delegate: string
fee: number
gas_limit: number
manager_pubkey: string
source: string
spendable: boolean
storage_limit: number
Ƭ TrezorRevealOperation: object
Defined in common/operations.ts:90
counter: number
fee: number
gas_limit: number
public_key: string
source: string
storage_limit: number
Ƭ TrezorTransactionOperation: object
Defined in common/operations.ts:99
amount: number
counter: number
destination: string
fee: number
gas_limit: number
source: string
storage_limit: number
Ƭ ValidationError: object
Defined in common/errors.ts:15
response: object
[]
state: S
Ƭ ValidationResult: object
Defined in common/state.ts:183
contents: OperationValidationResult[]
Ƭ Wallet: object
Defined in common/state.ts:187
Optional
mnemonic: undefined
| string
node: TezosNode
Optional
path: undefined
| string
Optional
publicKey: undefined
| string
publicKeyHash: string
Optional
secret: undefined
| string
Optional
secretKey: undefined
| string
Optional
type: "web" | "TREZOR_T" | "TREZOR_P"
Ƭ WalletDetail: object
Defined in common/state.ts:199
balance: number
▸ activateWallet<T
>(selector: function
): (Anonymous function)
Defined in wallet/activateWallet.ts:20
Activate generated wallet address
Type parameters:
T : State
Parameters:
Name | Type |
---|---|
selector | function |
Returns: (Anonymous function)
Observable
▸ applyAndInjectOperation<T
>(): (Anonymous function)
Defined in operation/applyInjectOperation.ts:26
Validates and inject operation into tezos blockain Can be applied to any prepared operation
Type parameters:
T : State & StateHead & StateOperations & StateSignOperation
Returns: (Anonymous function)
▸ base58CheckDecode(this: void
, prefix: Uint8Array
, encoded: string
): Buffer
Defined in common/crypto.ts:52
Decodes base58 encoded string into byte array and removes defined prefix
Parameters:
Name | Type | Description |
---|---|---|
this | void |
|
prefix | Uint8Array |
- |
encoded | string |
Returns: Buffer
▸ bs58checkEncode(this: void
, prefix: Uint8Array
, payload: Uint8Array
): string
Defined in common/crypto.ts:38
Encode byte array into base58check format using defined prefix
Parameters:
Name | Type | Description |
---|---|---|
this | void |
|
prefix | Uint8Array |
- |
payload | Uint8Array |
Returns: string
▸ checkPropertyWithError(o: Object
, propName: string
, methodName: string
): void
Defined in common/validation.ts:41
Ensure that defined property exists in object and throw syntax error if not
Parameters:
Name | Type | Description |
---|---|---|
o | Object |
object to check |
propName | string |
prop name |
methodName | string |
user friendly method name for better error tracking |
Returns: void
▸ concatKeys(this: void
, privateKey: Uint8Array
, publicKey: Uint8Array
): Uint8Array
Defined in common/crypto.ts:62
Concat together private and public key
Parameters:
Name | Type | Description |
---|---|---|
this | void |
|
privateKey | Uint8Array |
- |
publicKey | Uint8Array |
Returns: Uint8Array
▸ confirmOperation<T
>(selector: function
): (Anonymous function)
Defined in operation/confirmOperation.ts:21
Wait until operation is confirmed & moved from mempool to head
Polls mempool to check when operation is confirmed and moved to head
Type parameters:
T : State
Parameters:
Name | Type | Description |
---|---|---|
selector | function |
method returning operation hash to check in mempool |
Returns: (Anonymous function)
▸ constants<T
>(): (Anonymous function)
Defined in head/getConstants.ts:15
Get constants used in block
Type parameters:
T : State
Returns: (Anonymous function)
▸ counter<T
>(): (Anonymous function)
Defined in contract/getContractCounter.ts:16
Get contract counter
Type parameters:
T : State
Returns: (Anonymous function)
▸ forgeOperation<T
>(): (Anonymous function)
Defined in operation/forgeOperation.ts:27
Forge operation in blocchain. Converts operation into binary format and signs operation using script or Trezor
Type parameters:
T : State & StateOperations
Returns: (Anonymous function)
▸ forgeOperationAtomic<T
>(): (Anonymous function)
Defined in operation/forgeOperation.ts:69
Converts operation to binary format on node
Type parameters:
T : State & StateHead & StateOperations
Returns: (Anonymous function)
▸ getWallet<T
>(): (Anonymous function)
Defined in wallet/getWallet.ts:14
Get wallet details as balance
Type parameters:
T : State
Returns: (Anonymous function)
▸ hasAppliedOperationInMempool(this: StateConfirmOperation, operation: MempoolOperation): boolean
Defined in operation/confirmOperation.ts:68
Check if mempool contains operation among applied this: state with operation to confirm
Parameters:
Name | Type |
---|---|
this | StateConfirmOperation |
operation | MempoolOperation |
Returns: boolean
▸ hasRefusedOperationInMempool(this: StateConfirmOperation, operation: MempoolOperation): boolean
Defined in operation/confirmOperation.ts:59
Check if mempool contains operation among refused this: state with operation to confirm
Parameters:
Name | Type | Description |
---|---|---|
this | StateConfirmOperation | |
operation | MempoolOperation | mempool operation |
Returns: boolean
▸ head<T
>(): (Anonymous function)
Defined in head/getHead.ts:13
Get head for operation
Type parameters:
T : State
Returns: (Anonymous function)
▸ initializeWallet<T
>(selector: function
): (Anonymous function)
Defined in wallet/initializeWallet.ts:17
Waits for sodium to initialize and prepares wallet for working with it Should be the first step of every workflow
Type parameters:
T : Wallet
Parameters:
Name | Type |
---|---|
selector | function |
Returns: (Anonymous function)
▸ injectOperations<T
>(): (Anonymous function)
Defined in operation/applyInjectOperation.ts:81
Inbjects prevalidated operation to Tezos blockchain
Type parameters:
T : State & StateHead & StateOperations & StateSignOperation
Returns: (Anonymous function)
▸ keys(): WalletBase
▸ keys(mnemonic: string
, password: string
): WalletBase
Defined in common/crypto.ts:86
Generates wallet new wallet or uses provided mnemonic and password
Returns: WalletBase
Defined in common/crypto.ts:87
Parameters:
Name | Type |
---|---|
mnemonic | string |
password | string |
Returns: WalletBase
▸ managerKey<T
>(): (Anonymous function)
Defined in contract/getContractManagerKey.ts:13
Get manager key for contract
Type parameters:
T : State
Returns: (Anonymous function)
▸ newWallet(): (Anonymous function)
Defined in wallet/newWallet.ts:9
Generate new menomonic, private, public key & tezos wallet address
Returns: (Anonymous function)
▸ operation(): (Anonymous function)
Defined in operation/operation.ts:17
Create operation in blockchain. Fully forge operation, validates it and inject into blockchain
Returns: (Anonymous function)
▸ operationIsValid(operation: OperationValidationResult): boolean
Defined in operation/validateOperation.ts:108
Parameters:
Name | Type |
---|---|
operation | OperationValidationResult |
Returns: boolean
▸ originateContract<T
>(selector: function
): (Anonymous function)
Defined in contract/originateContract.ts:37
Originate smart contract from implicit wallet. Contract will be used for delegation. Complete operations stack
Type parameters:
T : State
Parameters:
Name | Type | Description |
---|---|---|
selector | function |
derives origination data from state |
Returns: (Anonymous function)
▸ packOperationParameters<T
>(): (Anonymous function)
Defined in operation/packOperationData.ts:14
Serialize operation parameters into binary format
Type parameters:
T : State & StateOperations
Returns: (Anonymous function)
▸ packOperationParametersAtomic<T
>(): (Anonymous function)
Defined in operation/packOperationData.ts:30
Serialize operation parameters on node
Type parameters:
T : State & StateOperations
Returns: (Anonymous function)
▸ parseAmount(this: void
, amount: string
): number
Defined in common/crypto.ts:76
Convert string amount notation into number in milions
Parameters:
Name | Type | Description |
---|---|---|
this | void |
|
amount | string |
text amount (3.50 tez) |
Returns: number
▸ pendingOperation<T
>(selector: function
): (Anonymous function)
Defined in operation/pendingOperation.ts:19
Gets list of applied and refused operations in mempool for specific wallet
Type parameters:
T : State
Parameters:
Name | Type | Description |
---|---|---|
selector | function |
method returning operation object with public key used as filter |
Returns: (Anonymous function)
▸ pendingOperationsAtomic<T
>(): (Anonymous function)
Defined in operation/pendingOperation.ts:51
Gets mempool operations
Type parameters:
T : State
Returns: (Anonymous function)
▸ preapplyOperations<T
>(): (Anonymous function)
Defined in operation/applyInjectOperation.ts:61
Prevalidates (preapply) operation on tezos node
Type parameters:
T : State & StateHead & StateSignOperation
Returns: (Anonymous function)
▸ ready(): Promise
<void
>
Defined in common/crypto.ts:114
Get sodium ready state
Returns: Promise
<void
>
▸ rpc<T
>(selector: function
): (Anonymous function)
Defined in common/rpc.ts:20
Remote procedure call (RPC) on tezos node Returns state object with rpc result under property defined in rpc parameters
Type parameters:
T : State
Parameters:
Name | Type | Description |
---|---|---|
selector | function |
method returning rpc parameters |
Returns: (Anonymous function)
▸ setDelegation<T
>(selector: function
): (Anonymous function)
Defined in delegate/setDelegate.ts:33
Set delegation rights to tezos address
Type parameters:
T : State
Parameters:
Name | Type | Description |
---|---|---|
selector | function |
provides data for delegation operation |
Returns: (Anonymous function)
▸ signOperation<T
>(state: T
): Observable
< T
& State & object
& object
& object
>
Defined in operation/signOperation.ts:45
Sign operation in state. Software signing is used. throws: TypeError when operation is not available in state
Type parameters:
T : State & StateHead & StateOperation
Parameters:
Name | Type | Description |
---|---|---|
state | T |
transaction state |
Returns: Observable
< T
& State & object
& object
& object
>
▸ signOperationTrezor<T
>(state: T
): Observable
< T
& State & object
& object
& object
>
Defined in operation/signOperation.ts:109
Sign operation using hardware Trezor wallet throws: Typerror when operation is not available
Type parameters:
T : State & StateHead & StateOperation
Parameters:
Name | Type | Description |
---|---|---|
state | T |
transaction state |
Returns: Observable
< T
& State & object
& object
& object
>
▸ transaction<T
>(selector: function
): (Anonymous function)
Defined in transaction/createTransaction.ts:39
Send amount to another wallet
Fully covers send useace and get transaction to blockchain
Type parameters:
T : State
Parameters:
Name | Type | Description |
---|---|---|
selector | function |
method returning transaction obejct |
Returns: (Anonymous function)
▸ updateFeesForOperation<T
>(): (Anonymous function)
Defined in operation/forgeOperation.ts:89
Estimates minimal fee for the operation and compares provided defined fees with minimal If provided fee is insuficient its overriden
When fee is modified operation has to be re-forged so signature is matching operation content
Type parameters:
T : State & StateHead & StateCounter & StateManagerKey & StateOperation & StateOperations
Returns: (Anonymous function)
▸ validateOperation<T
>(): (Anonymous function)
Defined in operation/validateOperation.ts:20
Validates operation on node to ensure, that operation can be executed and prefills gas consumption and storage size data
Type parameters:
T : State & StateHead & StateOperations
Returns: (Anonymous function)
▸ validateOperationAtomic<T
>(): (Anonymous function)
Defined in operation/validateOperation.ts:92
Serialize operation parameters on node
Type parameters:
T : State & StateHead & StateOperations & StateSignOperation
Returns: (Anonymous function)
▸ validateOriginationOperation(operation: OperationMetadata): void
Defined in common/validation.ts:27
Check origination operation metadata in runtime to prevent hidden failues
Parameters:
Name | Type |
---|---|
operation | OperationMetadata |
Returns: void
▸ validateRevealOperation(operation: OperationMetadata): void
Defined in common/validation.ts:6
Check reveal operation metadata in runtime to prevent hidden failues
Parameters:
Name | Type |
---|---|
operation | OperationMetadata |
Returns: void
▸ validateTransactionOperation(operation: OperationMetadata): void
Defined in common/validation.ts:16
Check transaction operation metadata in runtime to prevent hidden failues
Parameters:
Name | Type |
---|---|
operation | OperationMetadata |
Returns: void
prefix: object
Defined in common/crypto.ts:18
Prefix table
● B: Uint8Array
= new Uint8Array([1, 52])
Defined in common/crypto.ts:23
● KT1: Uint8Array
= new Uint8Array([2, 90, 121])
Defined in common/crypto.ts:22
● edpk: Uint8Array
= new Uint8Array([13, 15, 37, 217])
Defined in common/crypto.ts:24
● edsig: Uint8Array
= new Uint8Array([9, 245, 205, 134, 18])
Defined in common/crypto.ts:29
● edsk32: Uint8Array
= new Uint8Array([13, 15, 58, 7])
Defined in common/crypto.ts:28
● edsk64: Uint8Array
= new Uint8Array([43, 246, 78, 7])
Defined in common/crypto.ts:27
● operation: Uint8Array
= new Uint8Array([5, 116])
Defined in common/crypto.ts:30
● p2pk: Uint8Array
= new Uint8Array([3, 178, 139, 127])
Defined in common/crypto.ts:26
● sppk: Uint8Array
= new Uint8Array([3, 254, 226, 86])
Defined in common/crypto.ts:25
● tz1: Uint8Array
= new Uint8Array([6, 161, 159])
Defined in common/crypto.ts:19
● tz2: Uint8Array
= new Uint8Array([6, 161, 161])
Defined in common/crypto.ts:20
● tz3: Uint8Array
= new Uint8Array([6, 161, 164])
Defined in common/crypto.ts:21