Automated refunds
The goal here is to integrate a backend to send refunds through Mimic Protocol.
Task
import { ChainId, Transfer } from '@mimicprotocol/lib-ts'
import { inputs } from './types'
export default function main() {
Transfer
.create(ChainId.ETHEREUM, inputs.token, tokens.amount, inputs.recipient, inputs.fee)
.send()
console.log('Created transfer intent')
}
Manifest
version: 1.0.0
name: Client refunds
description: Refunds clients based on past orders
inputs:
- token: address
- amount: uint256
- recipient: address
- fee: uint256
Backend
import { EthersSigner } from 'ethers'
import { ConfigSigner } from '@mimicprotocol/sdk'
// Fetch the refund info from an external service
const { token, amount, recipient, fee } = await getRefundData()
// Submit the signed task config to Mimic Protocol
const signer = new ConfigSigner(EthersSigner.fromPrivateKey(env.process.PRIVATE_KEY))
await signer.executeOnce(
{ version: `refund-${Date.now()}` },
{ token, amount, recipient, fee }
)
Last updated