earn.createStack
Deploys deterministic EarnShare, EarnVault, and EarnFees contracts around an unbound engine. This API is experimental.
Usage
import { keccak256, toHex } from 'viem'
import { client } from './viem.config'
const result = await client.earn.createStackSync({
deploymentId: keccak256(toHex('acme-usd-v1')),
engine: '0x0000000000000000000000000000000000000001',
factory: '0x0000000000000000000000000000000000000002',
})
{ earnFees: '0x...', earnShare: '0x...', earnVault: '0x...', receipt: { ... } }import { Account, createClient } from 'viem/tempo'
export const client = createClient({
account: Account.fromSecp256k1('0x...'),
})Omitting fees deploys a fee-free stack. The emergency guardian and async janitor default to the
zero address, migration defaults to userOnly, managed assets are unlimited, and transfers use the
built-in always-allow policy.
Asynchronous Usage
earn.createStackSync waits for inclusion and returns the decoded deployment event. Use
earn.createStack to return the transaction hash immediately.
import { keccak256, toHex } from 'viem'
import { Actions } from 'viem/tempo'
import { client } from './viem.config'
const factory = '0x0000000000000000000000000000000000000002'
const hash = await client.earn.createStack({
deploymentId: keccak256(toHex('acme-usd-v1')),
engine: '0x0000000000000000000000000000000000000001',
factory,
})
const receipt = await client.waitForTransactionReceipt({ hash })
const { args } = Actions.earn.createStack.extractEvent(receipt.logs, {
factory,
})Return Value
type ReturnValue = {
/** Async janitor address. */
asyncJanitor: Address
/** Venue asset address. */
asset: Address
/** Control configuration hash. */
controlConfigHash: Hex
/** Deployment identifier. */
deploymentId: Hex
/** Deployed EarnFees address. */
earnFees: Address
/** Deterministic EarnFees salt. */
earnFeesSalt: Hex
/** Deployed EarnShare address. */
earnShare: Address
/** Deterministic EarnShare salt. */
earnShareSalt: Hex
/** Deployed EarnVault address. */
earnVault: Address
/** Emergency guardian address. */
emergencyGuardian: Address
/** ERC-4626 engine address. */
engine: Address
/** Fee configuration hash. */
feeConfigHash: Hex
/** Maximum managed assets. */
maxManagedAssets: bigint
/** Engine migration mode. */
migrationMode: number
/** Final stack owner and operator. */
owner: Address
/** Transaction receipt. */
receipt: TransactionReceipt
/** Effective transfer policy ID. */
transferPolicyId: bigint
}The asynchronous action returns the transaction hash instead.
Parameters
deploymentId
- Type:
Hex
A required, nonzero 32-byte identifier shared with the engine deployment.
engine
- Type:
Address
Unbound engine address.
factory
- Type:
Address
Reviewed EarnFactory address from the same release as the engine factory.
owner (optional)
- Type:
Account | Address - Default:
account.address
Final stack owner and operator.
controls (optional)
- Type:
EarnVaultControls
Initial emergencyGuardian, asyncJanitor, maxManagedAssets, and migrationMode controls.
fees (optional)
- Type:
EarnFeeConfiguration
Up to four fixed fees and an optional excess-return fee, all expressed in basis points. Omit this
parameter for a fee-free stack. When a distributor is enabled, fixedFees[0] is its protected fee
and the remaining entries are operator-controlled.
distributor (optional)
- Type:
EarnDistributorConfiguration
Protected distributor and update delay. An enabled distributor requires at least one fixed fee and
controls the first entry in fees.fixedFees through its delayed update path.
transferPolicyId (optional)
- Type:
bigint - Default:
0n
Existing simple whitelist policy. Zero selects the built-in always-allow policy.
account (optional)
- Type:
Account | Address
Account that will be used to send the transaction.
feeToken (optional)
- Type:
Address | bigint
Fee token for the transaction.
Can be an unpaused USD-denominated TIP-20 token address or ID. Use client.fee.validateToken({ token }) to validate a token before submitting a transaction or setting it as a fee preference.
feePayer (optional)
- Type:
Account | true
Fee payer for the transaction.
Can be a Viem Account, or true if a Fee Payer Service will be used.
gas (optional)
- Type:
bigint
Gas limit for the transaction.
maxFeePerGas (optional)
- Type:
bigint
Max fee per gas for the transaction.
maxPriorityFeePerGas (optional)
- Type:
bigint
Max priority fee per gas for the transaction.
nonce (optional)
- Type:
number
Nonce for the transaction.
nonceKey (optional)
- Type:
'expiring' | bigint
Nonce key for the transaction. Use 'expiring' to use expiring nonces (TIP-1009), which enables concurrent transaction submission without nonce ordering.
validBefore (optional)
- Type:
number
Unix timestamp before which the transaction must be included.
validAfter (optional)
- Type:
number
Unix timestamp after which the transaction can be included.
throwOnReceiptRevert (optional)
- Type:
boolean - Default:
true
Whether to throw an error if the transaction receipt indicates a revert. Only applicable to *Sync actions.