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 { ethers } from 'ethers'
import { Task } from '@mimicprotocol/sdk'

// Fetch the refund info from an external service
const { token, amount, recipient, fee } = await getRefundData()

// Prepare your task config data
const configData = {
  name: `refund-${Date.now()}`,
  data: { token, amount, recipient, fee }
}

// Submit the signed task config to Mimic Protocol
const wallet = new ethers.Wallet(env.process.PRIVATE_KEY)
const task = new Task('YOUR_TASK_ID', wallet)
await task.execute(configData)

Last updated