A guide on how to set up cross-chain royalty payments for your IP using deBridge.
test/6_DebridgeHook.t.sol
file. This already covers steps 1-3 below.
dlnHook
that will execute an arbitrary action upon order completion (ex. after $ETH has been swapped for $WIP).
In this case, the dlnHook
will be a call to payRoyaltyOnBehalf
on Story’s RoyaltyModule
contract, which will pay royalties to an IP Asset.
To summarize, we will construct a deBridge API call that says “we want to swap $ETH for $WIP, and then pay royalties using that $WIP to an IP Asset on Story”.
dlnHook
dlnHook
is a JSON object that will be attached to the deBridge API call. It will contain the following information:
evm_transaction_call
)ROYALTY_MODULE
)payRoyaltyOnBehalf
)dlnHook
, we can construct the whole deBridge API call, including the dlnHook
.
create-tx
endpoint here.Attribute | Description |
---|---|
srcChainId | The ID of the source blockchain (e.g., Ethereum mainnet is 1). |
srcChainTokenIn | The address of the token being swapped on the source chain (ETH in this case). |
srcChainTokenInAmount | The amount of the source token to swap, set to auto for automatic calculation. |
dstChainId | The ID of the destination blockchain (e.g., Story mainnet is 100000013). |
dstChainTokenOut | The address of the token to receive on the destination chain (WIP token). |
dstChainTokenOutAmount | The amount of the destination token to receive. It should be the same as the amount we’re paying in payRoyaltyOnBehalf in step 1a. |
dstChainTokenOutRecipient | This can just be the same as senderAddress . |
senderAddress | The address initiating the transaction. |
srcChainOrderAuthorityAddress | The address authorized to manage the order on the source chain. This can just be the same as senderAddress . |
dstChainOrderAuthorityAddress | The address authorized to manage the order on the destination chain. This can just be the same as senderAddress . |
enableEstimate | A flag to enable transaction simulation and estimation. |
prependOperatingExpenses | A flag to include operating expenses in the transaction. |
dlnHook | The URL-encoded hook that specifies additional actions to execute post-swap. |