How to integrate Paymaster on Abstract Chain with a simple API call?

Zyfi
12 Aug 202404:22

Summary

TLDRThis demo showcases integrating Sci-fi's API with a Dapp, highlighting its native account abstraction for gas usage. The focus is on enabling transactions paid in any token, exemplified by a mock ERC20 token on a testnet. The process includes connecting a wallet, using the API to execute transactions like token transfers without gas fees, and signing payloads with a wallet. The integration is simplified with tools like Rainbow Kit and Wagi, demonstrating a seamless user experience with Etherscan verification.

Takeaways

  • 🚀 The video is a demo on integrating Sci-Fi's API with a Dapp for gas abstraction.
  • 💳 Sci-Fi is a pay-as-a-service product that abstracts gas usage in blockchain interactions.
  • 💡 Gas sponsoring is a popular use case, allowing users to perform operations like submitting NFDs or executing swaps without gas fees.
  • 🔄 The demo focuses on enabling users to pay for transactions using any token, exemplified with a mock ERC20 token on a testnet.
  • 🎨 The presenter showcases a web design with a connected wallet balance for the mock token.
  • 🛰️ Interaction with the smart contract is done indirectly by sending a request to Sci-Fi's API, specifying the function, parameters, and payment token.
  • 🔑 The API responds with a payload that the user signs with their wallet, executing the transaction without token approvals.
  • 🔍 The demo includes transferring tokens between wallets, demonstrating the process on Etherscan and showing a small amount of tokens used to pay for the transaction.
  • 🛠️ Integration of Sci-Fi's API into code is shown using Rainbow Kit and Wagi for blockchain interaction on the custom Abstract testnet.
  • 📝 The script outlines steps for encoding functional data, preparing API requests, fetching responses, and creating a wallet client for transaction preparation.
  • 🔗 The final step is sending a transaction with the wallet client's signature and waiting for the receipt, completing the integration process.

Q & A

  • What is the main purpose of the demo presented in the script?

    -The main purpose of the demo is to show how to integrate sci-fi's API with a database to abstract gas usage when interacting with the blockchain, focusing on enabling users to pay for transactions using any token.

  • What is sci-fi's API and how does it relate to Master as a Service (DBaaS)?

    -Sci-fi's API is a service that allows for abstracting gas usage when interacting with the blockchain. It is related to DBaaS in the context of the demo as it provides a way to handle gas costs and token transactions without direct interaction with smart contracts.

  • What are the two popular use cases of sci-fi's API mentioned in the script?

    -The two popular use cases mentioned are gas sponsoring, which allows a DB to cover its user's gas cost, and enabling users to pay for transactions using any token.

  • Why is gas sponsoring a useful feature for users?

    -Gas sponsoring is useful because it allows users to perform operations such as submitting NFTs or executing swaps on a DEX without having to pay for the gas costs themselves.

  • What is the role of the mock ERC20 token in the demo?

    -The mock ERC20 token serves two purposes in the demo: it is used to pay for gas and also as the token for performing transfer transactions.

  • How does the API handle the process of transferring tokens without gas?

    -The API handles the process by sending a request specifying the function to call, its parameters, and the token for payment. It then responds with a payload that the user signs with their wallet, and the transaction is executed automatically.

  • What does the term 'abstract test net' refer to in the context of the demo?

    -The 'abstract test net' refers to a test network environment where the demo is deployed, allowing for the testing of the sci-fi API and its functionalities without using real assets.

  • How is the transaction executed after the user signs the payload from the API?

    -After the user signs the payload, the transaction is automatically executed by the system, without the need for token approvals, and the user's wallet is debited a small amount to pay for the transaction.

  • What is Etherscan and why is it mentioned in the demo?

    -Etherscan is a blockchain explorer that allows users to view transaction details on the Ethereum blockchain. It is mentioned in the demo to show the transaction details after the transfer of tokens.

  • How does the integration of sci-fi's API into the code work in the demo?

    -The integration involves setting up with Web3.js and using a custom chain (abstract test net), encoding the functional data for the transfer, preparing the API request payload, fetching the response, creating a wallet client, finding the user's latest nonce, and preparing the transaction data for the paymaster.

  • What is the final step in the integration process after preparing the transaction data?

    -The final step is to send the transaction, which triggers the signature from the wallet client, and then wait for the transaction receipt to confirm the transaction's completion.

Outlines

00:00

🚀 Introduction to Sci-fi API Integration

The speaker introduces a demonstration on integrating Sci-fi's API, a payment abstraction service that simplifies blockchain interactions by allowing gas usage to be abstracted. The focus is on two main use cases: gas sponsoring, where a platform can cover user gas costs for operations like submitting NFTs or executing swaps, and enabling transactions using any token. The demo utilizes the Abstract testnet and a mock ERC20 token for both gas payment and transfer transactions, showcasing a seamless user experience without direct smart contract interactions.

💻 Setting Up the Demo Environment

The speaker details the setup for the demo, which includes a beautiful web design with a connected wallet balance display for the mock token. The process involves sending requests to Sci-fi's API to specify the desired smart contract function, parameters, and payment token. The API then returns a payload for the user to sign with their wallet, executing the transaction automatically without the need for token approvals. The demo also includes a transfer of tokens between wallets, illustrating the transaction details on Etherscan.

🔄 Demonstrating Token Transfer without Gas Guess

In this part of the demo, the speaker performs a token transfer between two wallets without any gas fees paid by the user. The transaction is executed by the payMaster, with a small amount of tokens deducted from the user's wallet to cover the transaction costs. The speaker emphasizes the ease of integrating Sci-fi's API into code, using Rainbow Kit and Wagi with custom chain setup for the Abstract testnet.

🛠️ Integrating Sci-fi API into Code

The speaker outlines the steps to integrate Sci-fi's API into code, starting with encoding the functional data for a transfer, preparing the API request payload with chain ID, fee token, and transaction data. The process continues with fetching the API response, creating a wallet client configured for EIP 712 actions, finding the user's latest nonce, and preparing transaction data for the payMaster using the API response. The final step is to send a transaction that triggers the signature from the wallet client and waits for the receipt, completing the integration process.

Mindmap

Keywords

💡API

API stands for Application Programming Interface, which is a set of rules and protocols for building and interacting with software applications. In the context of the video, the API is used to integrate with sci-fi's service, allowing for the abstraction of gas usage when interacting with the blockchain. The video demonstrates how to send a request to sci-fi's API to specify which smart contract function to call, along with the parameters and the token to be used for payment.

💡Gas Usage

Gas usage in the context of blockchain refers to the computational effort required to perform transactions or execute smart contracts, which is often associated with a cost in the native cryptocurrency of the blockchain. The video discusses how sci-fi's service can abstract gas usage, allowing for operations like NFT submissions or DEX trades to be performed without the user directly paying for the gas.

💡Native Account Abstraction

Native account abstraction is a feature that allows users to interact with a blockchain without having to manage their own private keys. The video mentions this as a feature of sci-fi's service, which can cover user gas costs, enhancing the user experience by abstracting the complexities of direct blockchain interaction.

💡Gas Sponsoring

Gas sponsoring is a service where a third party, such as a decentralized application (DApp), covers the gas costs for users when they perform certain operations on the blockchain. The video uses this as an example of how sci-fi's service can facilitate users submitting NFTs or executing swaps on a DEX without incurring gas fees.

💡Smart Contract

A smart contract is a self-executing contract with the terms of the agreement directly written into code. The video discusses how users can interact with smart contracts via sci-fi's API, abstracting the need for direct interaction and allowing for operations like token transfers to be executed seamlessly.

💡ERC20 Token

ERC20 is a standard for fungible tokens on the Ethereum blockchain. The video mentions deploying a mock ERC20 token on the abstract test net, which serves dual purposes: it is used both to pay for gas and to perform transfer transactions, demonstrating the flexibility of using tokens for different blockchain operations.

💡Test Net

A test net is a separate blockchain network used for testing purposes, distinct from the main network. The video uses the abstract test net for the demo, allowing for safe experimentation without the risk of using real assets or funds.

💡EIP 712

EIP 712 is a proposal for a domain-specific message format for signing transactions, which improves the security and user experience of signing messages in Ethereum applications. The video mentions extending the wallet client with EIP 712 actions, which is part of the process to prepare and sign transactions using sci-fi's API.

💡Wallet Client

A wallet client is a software application that allows users to manage their cryptocurrency assets, interact with blockchain networks, and sign transactions. In the video, a wallet client is created and used to sign transactions, which are then executed on the blockchain after being prepared with sci-fi's API.

💡Transaction Data

Transaction data refers to the information included in a blockchain transaction, such as the recipient address, the amount of cryptocurrency to be transferred, and any additional parameters required by the smart contract. The video explains how to encode functional data for a transfer and prepare this data for submission to the paymaster via sci-fi's API.

💡Paymaster

A paymaster is an entity or service that pays for the gas fees of transactions on behalf of the user. The video focuses on integrating with sci-fi's paymaster service, which allows transactions to be paid using any token, providing flexibility and convenience to users.

Highlights

Introduction to a demo on integrating sci-fi's API with a database.

sci-fi is a pay-as-a-service product for abstracting gas usage in blockchain interactions.

Gas sponsoring allows a DB to cover user gas costs for smart contract operations.

Demonstration of enabling users to pay for transactions using any token.

Use of the abstract test net and deployment of a mock ERC20 token for demo purposes.

The mock token serves the dual purpose of paying for gas and performing transfer transactions.

Overview of the web design used in the demo and its features.

Explanation of how to interact with the smart contract via sci-fi's API instead of directly.

Process of sending a request to sci-fi's API specifying the desired function and payment token.

The API's response includes a payload for the user to sign with their wallet.

Automatic execution of the transaction after signing without token approvals.

Transfer of tokens between wallets without gas fees demonstrated.

Etherscan verification of transaction details and gas payment by pay-Master.

Integration of sci-fi's API into code using Rainbow Kit and Wagi NVM.

Setup of the custom chain, abstract test net, with WME for blockchain interaction.

Simple steps to integrate sci-fi API calls in the codebase.

Encoding of functional data for the transfer in the API request payload.

Fetching the API response and creating a wallet client with EIP 712 actions.

Preparation of transaction data for pay-Master using the API response.

Final step of sending the transaction with wallet client signature and waiting for the receipt.

Transcripts

play00:02

hey everyone today I'm going to show you

play00:05

a quick demo on how to integrate

play00:06

sci-fi's API with your daab zfi is a pay

play00:10

Master as a service product that allows

play00:12

you to abstract gas usage when

play00:14

interacting with the blockchain using

play00:15

native account

play00:17

abstraction one of our most popular use

play00:19

cases is gas sponsoring which lets a DB

play00:22

cover its user gas cost when when

play00:24

performing operations against its smart

play00:27

contract for example this could allow

play00:29

users submit nfds or execute swaps on a

play00:32

particular dep for free another use case

play00:35

which is the focus of this demo is

play00:37

enabling users to pay for a transaction

play00:39

using any token for this example I'll be

play00:43

using the abstract test net since it's a

play00:46

test net I've deployed a mock erc20

play00:48

token that will serve us two purposes it

play00:51

will be the token used to pay for gas

play00:53

and also the one we use to perform

play00:55

transfer

play00:58

transactions first let's admire this

play01:00

beautiful web design that I put together

play01:03

at the bottom you can see the current

play01:05

balance of the connected wallet for a

play01:07

mop

play01:08

token notice that none of the wallets

play01:10

that I'm using in this demo have any

play01:13

e instead of interacting directly with

play01:16

the smart contract I'll send a request

play01:18

to zi's API specifying which function I

play01:21

want to call it's parameters and the

play01:24

token I want to use for payment the API

play01:27

will work its magic and respond with the

play01:29

payload that the user will sign with

play01:31

their wallet once signed the transaction

play01:33

is automatically executed without the

play01:35

need for token

play01:40

approvals next I'm going to transfer a

play01:42

few tokens between those two wallets

play01:44

without any guess and we'll see what it

play01:46

looks like on ether scan

play02:26

notice that a small amount of tokens

play02:28

came out of the user's wallet to the pay

play02:30

Master to pay for the transaction while

play02:33

the transaction itself was paid by the

play02:35

pay

play02:42

Master now I'm going to show you how

play02:44

easy it is to integrate sci-fi's API

play02:47

into your

play02:48

code for our demo I'm using rainbow kit

play02:52

wagi NVM for interacting with the

play02:57

blockchain because we're using a custom

play02:59

chain which is abstract test net this is

play03:02

how I set it up with

play03:09

WME finally let's see how simple it is

play03:11

to integrate sci-fi API

play03:15

calls remember this is the mock token

play03:18

address that we're going to be using

play03:19

both for fees and for the transfers this

play03:23

is the function that gets called when

play03:25

the user clicks the button on our front

play03:27

end step number one you encode the

play03:29

functional data for the

play03:31

transfer step two you prepare the API

play03:34

request payload specifying the chain ID

play03:37

the token that are is going to be used

play03:40

for fees and the transaction

play03:42

data step three you fetch the response

play03:45

from the

play03:46

API step four you create a wallet client

play03:52

based on our configuration and extended

play03:55

with the EIP 712

play03:58

actions step step five you find the

play04:00

users's latest Nots and step six you

play04:03

prepare the transaction data for the pay

play04:05

Master using the response from the

play04:08

API all you need to do now is send a

play04:10

transaction which is going to fire um

play04:13

the signature from your wallet clients

play04:16

and wait for the

play04:17

receipt you're done

Rate This

5.0 / 5 (0 votes)

Étiquettes Connexes
BlockchainAPI IntegrationGas SponsorshipToken PaymentsSmart ContractsTestnet DemoEthereumWallet BalanceTransaction FeesCryptocurrency
Besoin d'un résumé en anglais ?