Skip to main content

EvmTeleportSDK

EvmTeleportSDK is a concrete implementation of TeleportSDK specifically designed to work with Ethereum-based blockchains. This class extends the core functionalities of the SDK to efficiently interact with smart contracts and vendors within the Ethereum ecosystem, adapting and extending TeleportSDK capabilities to meet the specific requirements of EVM (Ethereum Virtual Machine) type blockchains.

Main features

  • Interaction with Smart Contracts: EvmTeleportSDK facilitates interactions with smart contracts through the use of project-specific ABIs (Application Binary Interfaces), enabling seamless and secure integration with various contract functions.
  • Transaction and Rate Management: Provides methods to calculate and manage fees related to transportation and services within the Ethereum network, which includes teleportation fees and provider service fees.
  • Support for Ethereum Data Types: Uses specific data types such as BigNumber from the ethers library, essential for handling the peculiarities of cryptographic and financial transactions in Ethereum.

Initialization

The initialize method of EvmTeleportSDK serves three main functions during the configuration of the SDK for Ethereum-based blockchains. First, it verifies that the provided signerOrProvider is valid for EVM environments, ensuring compatibility and functionality. Next, it invokes the initialize method of the TeleportSDK base class to set general configurations. Finally, it determines whether the environment will operate in read-only or write-only mode, based on whether the signerOrProvider has signing capabilities, which is crucial for performing operations that require direct interaction with the blockchain.

Implementation of TeleportSDK abstract methods

EvmTeleportSDK overrides several abstract methods defined in the TeleportSDK base class, adapting them specifically to work inside Ethereum-based blockchains.

getChainIdent

getChainIdent(): Promise<string>

It uses the signerOrProvider to obtain the identifier of the current chain. This method is crucial to ensure that the SDK operates on the correct chain and performs valid transactions within the context of the Ethereum network.

deliver

deliver(transmission: DeliverableTransmission, providerAddress?: string): PayableCall

Manages the delivery of transmissions, using the defined teleport contract. Uses the provider set in the config if one is not provided as a parameter.

getTeleportFee

getTeleportFee(): Promise<BigNumber>

Calculates the fee associated with the use of the teleport service, obtaining the value directly from the teleport contract.

getProviderFee

getProviderFee({ targetChainId, transmissionReceiver, dAppId, payload, extraArgs, providerAddress }): Promise<BigNumber>

Determines the fee associated with the service provider for a specific transaction, considering the target chain, receiver, dApp ID, and payload, using the providerFee method of the teleport contract.

getServiceFee

getServiceFee({ targetChainId, transmissionReceiver, dAppId, payload, extraArgs, providerAddress }): Promise<BigNumber>

Calculates the total fee for a transaction, which includes both the teleport fee and the provider fee, using the getServiceFee method of the teleport contract.

getTeleportContract()

getTeleportContract(): Contract

Returns the teleport contract instance used by the SDK to interact with the teleport service on the Ethereum network.

getProviderContract()

getProviderContract(): Contract

Returns the provider contract using the providerSelector contract. Currently, the providerSelector returns default provider contract.

If there would be other provider selector in the future, this method might not be available.

getProviderSupportedChains()

getProviderSupportedChains(): Promise<number[]>

Returns the list of chain IDs supported by the provider contract.