@celo/connect › "connection" › Connection
Class: Connection
Hierarchy
- Connection
Index
Constructors
Properties
Accessors
Methods
- addAccount
- chainId
- coinbase
- estimateGas
- estimateGasWithInflationFactor
- fillGasPrice
- gasPrice
- getAbiCoder
- getAccounts
- getBalance
- getBlock
- getBlockHeader
- getBlockNumber
- getLocalAccounts
- getNodeAccounts
- getTransaction
- getTransactionCount
- getTransactionReceipt
- isListening
- isLocalAccount
- isSyncing
- nonce
- removeAccount
- sendSignedTransaction
- sendTransaction
- sendTransactionObject
- setGasPriceForCurrency
- setProvider
- sign
- signTypedData
- stop
Constructors
constructor
+ new Connection(web3
: Web3, wallet?
: ReadOnlyWallet, handleRevert
: boolean): Connection
Defined in packages/sdk/connect/src/connection.ts:54
Parameters:
Name | Type | Default |
---|---|---|
web3 |
Web3 | - |
wallet? |
ReadOnlyWallet | - |
handleRevert |
boolean | true |
Returns: Connection
Properties
Readonly
paramsPopulator
• paramsPopulator: TxParamsNormalizer
Defined in packages/sdk/connect/src/connection.ts:50
rpcCaller
• rpcCaller: RpcCaller
Defined in packages/sdk/connect/src/connection.ts:51
Optional
wallet
• wallet? : ReadOnlyWallet
Defined in packages/sdk/connect/src/connection.ts:56
Readonly
web3
• web3: Web3
Defined in packages/sdk/connect/src/connection.ts:56
Accessors
defaultAccount
• get defaultAccount(): Address | undefined
Defined in packages/sdk/connect/src/connection.ts:100
Default account for generated transactions (eg. tx.from)
Returns: Address | undefined
• set defaultAccount(address
: Address | undefined): void
Defined in packages/sdk/connect/src/connection.ts:92
Set default account for generated transactions (eg. tx.from )
Parameters:
Name | Type |
---|---|
address |
Address | undefined |
Returns: void
defaultFeeCurrency
• get defaultFeeCurrency(): undefined | string
Defined in packages/sdk/connect/src/connection.ts:132
Set the ERC20 address for the token to use to pay for transaction fees. The ERC20 must be whitelisted for gas.
Set to null
to use CELO
Returns: undefined | string
• set defaultFeeCurrency(address
: Address | undefined): void
Defined in packages/sdk/connect/src/connection.ts:128
Set the ERC20 address for the token to use to pay for transaction fees. The ERC20 must be whitelisted for gas.
Set to null
to use CELO
Parameters:
Name | Type | Description |
---|---|---|
address |
Address | undefined | ERC20 address |
Returns: void
defaultGasInflationFactor
• get defaultGasInflationFactor(): number
Defined in packages/sdk/connect/src/connection.ts:108
Returns: number
• set defaultGasInflationFactor(factor
: number): void
Defined in packages/sdk/connect/src/connection.ts:104
Parameters:
Name | Type |
---|---|
factor |
number |
Returns: void
defaultGasPrice
• get defaultGasPrice(): number
Defined in packages/sdk/connect/src/connection.ts:116
Returns: number
• set defaultGasPrice(price
: number): void
Defined in packages/sdk/connect/src/connection.ts:112
Parameters:
Name | Type |
---|---|
price |
number |
Returns: void
Methods
addAccount
▸ addAccount(privateKey
: string): void
Defined in packages/sdk/connect/src/connection.ts:140
Parameters:
Name | Type |
---|---|
privateKey |
string |
Returns: void
chainId
▸ chainId(): Promise‹number›
Defined in packages/sdk/connect/src/connection.ts:373
Returns: Promise‹number›
coinbase
▸ coinbase(): Promise‹string›
Defined in packages/sdk/connect/src/connection.ts:390
Returns: Promise‹string›
estimateGas
▸ estimateGas(tx
: CeloTx, gasEstimator
: function, caller
: function): Promise‹number›
Defined in packages/sdk/connect/src/connection.ts:326
Parameters:
▪ tx: CeloTx
▪Default value
gasEstimator: function= this.web3.eth.estimateGas
▸ (tx
: CeloTx): Promise‹number›
Parameters:
Name | Type |
---|---|
tx |
CeloTx |
▪Default value
caller: function= this.web3.eth.call
▸ (tx
: CeloTx): Promise‹string›
Parameters:
Name | Type |
---|---|
tx |
CeloTx |
Returns: Promise‹number›
estimateGasWithInflationFactor
▸ estimateGasWithInflationFactor(tx
: CeloTx, gasEstimator?
: undefined | function, caller?
: undefined | function): Promise‹number›
Defined in packages/sdk/connect/src/connection.ts:357
Parameters:
Name | Type |
---|---|
tx |
CeloTx |
gasEstimator? |
undefined | function |
caller? |
undefined | function |
Returns: Promise‹number›
fillGasPrice
▸ fillGasPrice(tx
: CeloTx): CeloTx
Defined in packages/sdk/connect/src/connection.ts:312
Parameters:
Name | Type |
---|---|
tx |
CeloTx |
Returns: CeloTx
gasPrice
▸ gasPrice(feeCurrency?
: Address): Promise‹string›
Defined in packages/sdk/connect/src/connection.ts:396
Parameters:
Name | Type |
---|---|
feeCurrency? |
Address |
Returns: Promise‹string›
getAbiCoder
▸ getAbiCoder(): AbiCoder
Defined in packages/sdk/connect/src/connection.ts:353
Returns: AbiCoder
getAccounts
▸ getAccounts(): Promise‹string[]›
Defined in packages/sdk/connect/src/connection.ts:173
Returns: Promise‹string[]›
getBalance
▸ getBalance(address
: Address, defaultBlock?
: BlockNumber): Promise‹string›
Defined in packages/sdk/connect/src/connection.ts:443
Parameters:
Name | Type |
---|---|
address |
Address |
defaultBlock? |
BlockNumber |
Returns: Promise‹string›
getBlock
▸ getBlock(blockHashOrBlockNumber
: BlockNumber, fullTxObjects
: boolean): Promise‹Block›
Defined in packages/sdk/connect/src/connection.ts:415
Parameters:
Name | Type | Default |
---|---|---|
blockHashOrBlockNumber |
BlockNumber | - |
fullTxObjects |
boolean | true |
Returns: Promise‹Block›
getBlockHeader
▸ getBlockHeader(blockHashOrBlockNumber
: BlockNumber): Promise‹BlockHeader›
Defined in packages/sdk/connect/src/connection.ts:431
Parameters:
Name | Type |
---|---|
blockHashOrBlockNumber |
BlockNumber |
Returns: Promise‹BlockHeader›
getBlockNumber
▸ getBlockNumber(): Promise‹number›
Defined in packages/sdk/connect/src/connection.ts:406
Returns: Promise‹number›
getLocalAccounts
▸ getLocalAccounts(): string[]
Defined in packages/sdk/connect/src/connection.ts:169
Returns: string[]
getNodeAccounts
▸ getNodeAccounts(): Promise‹string[]›
Defined in packages/sdk/connect/src/connection.ts:164
Returns: Promise‹string[]›
getTransaction
▸ getTransaction(transactionHash
: string): Promise‹CeloTxPending›
Defined in packages/sdk/connect/src/connection.ts:452
Parameters:
Name | Type |
---|---|
transactionHash |
string |
Returns: Promise‹CeloTxPending›
getTransactionCount
▸ getTransactionCount(address
: Address): Promise‹number›
Defined in packages/sdk/connect/src/connection.ts:379
Parameters:
Name | Type |
---|---|
address |
Address |
Returns: Promise‹number›
getTransactionReceipt
▸ getTransactionReceipt(txhash
: string): Promise‹CeloTxReceipt | null›
Defined in packages/sdk/connect/src/connection.ts:460
Parameters:
Name | Type |
---|---|
txhash |
string |
Returns: Promise‹CeloTxReceipt | null›
isListening
▸ isListening(): Promise‹boolean›
Defined in packages/sdk/connect/src/connection.ts:181
Returns: Promise‹boolean›
isLocalAccount
▸ isLocalAccount(address?
: Address): boolean
Defined in packages/sdk/connect/src/connection.ts:136
Parameters:
Name | Type |
---|---|
address? |
Address |
Returns: boolean
isSyncing
▸ isSyncing(): Promise‹boolean›
Defined in packages/sdk/connect/src/connection.ts:185
Returns: Promise‹boolean›
nonce
▸ nonce(address
: Address): Promise‹number›
Defined in packages/sdk/connect/src/connection.ts:386
Parameters:
Name | Type |
---|---|
address |
Address |
Returns: Promise‹number›
removeAccount
▸ removeAccount(address
: string): void
Defined in packages/sdk/connect/src/connection.ts:152
Parameters:
Name | Type |
---|---|
address |
string |
Returns: void
sendSignedTransaction
▸ sendSignedTransaction(signedTransactionData
: string): Promise‹TransactionResult›
Defined in packages/sdk/connect/src/connection.ts:307
Parameters:
Name | Type |
---|---|
signedTransactionData |
string |
Returns: Promise‹TransactionResult›
sendTransaction
▸ sendTransaction(tx
: CeloTx): Promise‹TransactionResult›
Defined in packages/sdk/connect/src/connection.ts:209
Send a transaction to celo-blockchain.
Similar to web3.eth.sendTransaction()
but with following differences:
- applies kit tx's defaults
- estimatesGas before sending
- returns a TransactionResult
instead of PromiEvent
Parameters:
Name | Type |
---|---|
tx |
CeloTx |
Returns: Promise‹TransactionResult›
sendTransactionObject
▸ sendTransactionObject(txObj
: CeloTxObject‹any›, tx?
: Omit‹CeloTx, "data"›): Promise‹TransactionResult›
Defined in packages/sdk/connect/src/connection.ts:226
Parameters:
Name | Type |
---|---|
txObj |
CeloTxObject‹any› |
tx? |
Omit‹CeloTx, "data"› |
Returns: Promise‹TransactionResult›
setGasPriceForCurrency
▸ setGasPriceForCurrency(address
: Address, gasPrice
: string): Promise‹void›
Defined in packages/sdk/connect/src/connection.ts:322
Parameters:
Name | Type |
---|---|
address |
Address |
gasPrice |
string |
Returns: Promise‹void›
setProvider
▸ setProvider(provider
: Provider): boolean
Defined in packages/sdk/connect/src/connection.ts:73
Parameters:
Name | Type |
---|---|
provider |
Provider |
Returns: boolean
sign
▸ sign(dataToSign
: string, address
: Address | number): Promise‹string›
Defined in packages/sdk/connect/src/connection.ts:280
Parameters:
Name | Type |
---|---|
dataToSign |
string |
address |
Address | number |
Returns: Promise‹string›
signTypedData
▸ signTypedData(signer
: string, typedData
: EIP712TypedData): Promise‹Signature›
Defined in packages/sdk/connect/src/connection.ts:252
Parameters:
Name | Type |
---|---|
signer |
string |
typedData |
EIP712TypedData |
Returns: Promise‹Signature›
stop
▸ stop(): void
Defined in packages/sdk/connect/src/connection.ts:486
Returns: void