@dynamic-labs-sdk/tempo
v1.50.0
Published
This package contains the Tempo integration for the Dynamic SDK.
Readme
@dynamic-labs-sdk/tempo
This package contains the Tempo integration for the Dynamic SDK.
Tempo is an EVM-compatible chain with no native token — fees and transfers are paid in TIP-20 stablecoins.
Installation
npm install @dynamic-labs-sdk/tempoUsage
import { createDynamicClient } from '@dynamic-labs-sdk/client';
import { addTempoExtension } from '@dynamic-labs-sdk/tempo';
const dynamicClient = createDynamicClient({
environmentId: '123',
});
addTempoExtension(dynamicClient);Once the extension is registered, the package exposes helpers for working with Tempo wallets and networks:
isTempoWalletAccount/isTempoWalletProvider/isTempoNetworkProvider— type guards that narrow a value to its Tempo-specific type.getTempoPublicClient— returns a viemPublicClientfor the active Tempo network.sendTip20Transaction— sends a TIP-20 token transfer (Tempo has no native token, so a token contract address is always required).
import {
getTempoPublicClient,
isTempoWalletAccount,
sendTip20Transaction,
} from '@dynamic-labs-sdk/tempo';
if (isTempoWalletAccount(walletAccount)) {
const publicClient = await getTempoPublicClient(
{ walletAccount },
dynamicClient
);
const blockNumber = await publicClient.getBlockNumber();
const transactionHash = await sendTip20Transaction({
amount: '1.5',
to: '0xRecipient',
tokenAddress: '0xTip20Token',
walletClient,
});
}Embedded wallets
Embedded wallet support is available from the /waas entry point:
import { addTempoExtension } from '@dynamic-labs-sdk/tempo';
import { addWaasTempoExtension } from '@dynamic-labs-sdk/tempo/waas';
addTempoExtension(dynamicClient);
addWaasTempoExtension(dynamicClient);Embedded Tempo wallets can sign messages and EIP-712 typed data, transfer
TIP-20 tokens with transferAmount, and send transactions with a viem wallet
client from the wallet provider's createViemWalletClient.
Sending a Tempo transaction
Use sendTempoTransaction for transactions that use Tempo-only fields: batched
calls, a fee token, a nonce key, or a validity window.
import { sendTempoTransaction } from '@dynamic-labs-sdk/tempo/waas';
const { transactionHash } = await sendTempoTransaction({
calls: [
{ data: transferData, to: tokenAddress },
{ data: approveData, to: tokenAddress },
],
feeToken: tokenAddress,
walletAccount,
});Gas defaults to a buffered estimate, and the nonce is the next nonce on the requested nonce lane.
Signing for a fee sponsor
Use signTempoTransaction with awaitingFeePayer to sign a transaction whose
fee someone else pays. The sender signs first and the function returns the
signed transaction without broadcasting it. The sponsor signs that transaction
afterwards and broadcasts it.
import { signTempoTransaction } from '@dynamic-labs-sdk/tempo/waas';
const { signedTransaction } = await signTempoTransaction({
awaitingFeePayer: true,
calls: [{ data: transferData, to: tokenAddress }],
walletAccount,
});The sponsor chooses the fee token, so awaitingFeePayer cannot be combined with
feeToken. sendTempoTransaction rejects awaitingFeePayer because a
transaction that still awaits its fee payer cannot be broadcast.
