Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ERC: Public Cross Port #62

Merged
merged 33 commits into from
Feb 2, 2024
Merged
Changes from 1 commit
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
3048328
Create eip-xxxx.md
JXRow Apr 24, 2023
a4f32ac
Update eip-xxxx.md
JXRow Apr 24, 2023
4b4337f
draft cross eip
JXRow Sep 26, 2023
80d3192
Update eip-xxxx.md
JXRow Sep 27, 2023
c65c0c1
Update EIP number
JXRow Oct 11, 2023
6e26729
Lint
JXRow Oct 11, 2023
53c43fd
update EIP number to 7533
JXRow Oct 12, 2023
60ebbf6
update eip to erc
JXRow Oct 30, 2023
3cf5fa7
Remove files
JXRow Oct 31, 2023
4d3602e
Create eip-xxxx.md
JXRow Apr 24, 2023
d91c456
Update eip-xxxx.md
JXRow Apr 24, 2023
53e4e4b
draft cross eip
JXRow Sep 26, 2023
c914141
Update eip-xxxx.md
JXRow Sep 27, 2023
8fbbc97
Update EIP number
JXRow Oct 11, 2023
0bebbbd
Lint
JXRow Oct 11, 2023
a37f75a
update EIP number to 7533
JXRow Oct 12, 2023
0bb1346
update eip to erc
JXRow Oct 30, 2023
a74c116
Remove files
JXRow Oct 31, 2023
28e827f
Update erc-7533.md
JXRow Dec 8, 2023
74f79d1
Merge branch 'master' into cross
JXRow Jan 18, 2024
11cc006
Update erc-7533.md
JXRow Jan 18, 2024
a2c3045
Update erc-7533.md
JXRow Jan 18, 2024
5e6f507
Update erc-7533.md
JXRow Jan 18, 2024
e8531ef
Update ERCS/erc-7533.md
JXRow Jan 19, 2024
1fcdabf
Update ERCS/erc-7533.md
JXRow Jan 19, 2024
3e0a821
moved to Specification
JXRow Jan 19, 2024
abb2b21
Recommended changed to Suggestions
JXRow Jan 19, 2024
02bbe87
Merge branch 'master' into cross
JXRow Jan 19, 2024
44c064a
Update erc-7533.md
JXRow Jan 20, 2024
6836d77
Merge branch 'cross' of https://github.com/JXRow/ERCs into cross
JXRow Jan 20, 2024
880676e
Merge branch 'master' into cross
JXRow Jan 23, 2024
3be1b5a
Merge branch 'master' into cross
JXRow Jan 25, 2024
8491fa8
Merge branch 'master' into cross
JXRow Jan 31, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Create eip-xxxx.md
  • Loading branch information
JXRow committed Jan 4, 2024
commit 4d3602eefc5e3e7d1d52ef2b09be452193c997e9
156 changes: 156 additions & 0 deletions ERCS/eip-xxxx.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
---
eip: xxxx
title: Batch Calls JSON Schema
description: Give the details of each call to the wallet
author: George (@JXRow)
discussions-to: https://ethereum-magicians.org/t/batch-calls-json-schema/13935
status: Draft
type: Standards Track
category: ERC
created: 2023-04-24
---


## Abstract

Batch Calls JSON Schema aims to define a JSON from apps to wallet.


## Motivation

Batch calls we use oftenly, like approve then swap, approve then transferFrom, user needs to confirm twice or more in wallet, we put the calls into a JSON, so that the wallet can deal the calls automatic in just one confirm.


### Use case

This JSON Schema is a suggetion to apps and wallet, it dosen't modify smart contracts or RPC-JSON. Just give the details of each call to the wallet.

- The total spend(that’s what user really care about) can be calculated before submit.
- It's much useful for Smart Contract Wallet (Account Abstraction), which can batch calls into one Tx.
- RPC info is given, user needn't to manual connect wallet or switch RPC, it can be automatic done by wallet.
- The data transfer is one direction, wallet needn't return data back to the apps, all user operations can be done in a QR code, scan and confirm.


## Specification

The key words “MUST”, “MUST NOT”, “REQUIRED”, “SHALL”, “SHALL NOT”, “SHOULD”, “SHOULD NOT”, “RECOMMENDED”, “MAY”, and “OPTIONAL” in this document are to be interpreted as described in RFC 2119.

A simple Batch Calls JSON Schema is:

```solidity
{
rpc: {
name: 'Scroll_Alpha',
url: 'https://alpha-rpc.scroll.io/l2',
chainId: 534353
},
calls: [
{
to: '0x67aE69Fd63b4fc8809ADc224A9b82Be976039509',
value: '0',
abi: 'function transfer(address to, uint256 amount)',
params: [
'0xE44081Ee2D0D4cbaCd10b44e769A14Def065eD4D',
'1000000'
]
},
{
to: '0xE44081Ee2D0D4cbaCd10b44e769A14Def065eD4D',
value: '1000000000000000',
abi: '',
params: []
}
]
}
```

- `rpc` : REQUIRED
- `name` : OPTIONAL, wallet SHALL use its stored RPC info instead.
- `url` : OPTIONAL, wallet SHALL use its stored RPC info instead.
- `chainId` : REQUIRED
- `calls` : REQUIRED, the calls array.
- `to` : REQUIRED, smart contract address or wallet address
- `value` : REQUIRED, ETH amount (wei)
- `abi` : REQUIRED, The abi MAY be a JSON string or the parsed Object (using JSON.parse) which is emitted by the [Solidity compiler](https://solidity.readthedocs.io/en/v0.6.0/using-the-compiler.html#output-description) (or compatible languages).<br>
The abi MAY also be a [Human-Readable](https://blog.ricmoo.com/human-readable-contract-abis-in-ethers-js-141902f4d917) Abi, which is a format the Ethers created to simplify manually typing the ABI into the source and so that a Contract ABI can also be referenced easily within the same source file.
The abi SHOULD be empty string if it's not a contract call.
- `params` : REQUIRED, the params to this contract function call.
The params SHOULD be empty array if it's not a contract call.


## Example

A complex example is:

```javascript
const { BigNumber, utils } = require('ethers')

let swapData = utils.defaultAbiCoder.encode(
['address', 'address', 'uint8'],
[USDC_ADDRESS, WALLET_ADDRESS, 1] // tokenIn, to, withdraw mode
)

let json = {
rpc: {
name: 'Scroll_Alpha',
url: 'https://alpha-rpc.scroll.io/l2',
chainId: 534353
},
calls: [
{
to: USDC_ADDRESS,
value: '0',
abi: 'function approve(address spender, uint256 amount)',
params: [
ROUTER_ADDRESS,
'1000000'
]
},
{
to: ROUTER_ADDRESS,
value: '0',
abi: 'function swap(tuple(tuple(address pool, bytes data, address callback, bytes callbackData)[] steps, address tokenIn, uint256 amountIn)[] paths, uint amountOutMin, uint deadline) returns (uint amountOut)',
params: [
[{
steps: [{
pool: POOL_ADDRESS,
data: swapData,
callback: ZERO_ADDRESS,
callbackData: '0x',
}],
tokenIn: USDC_ADDRESS,
amountIn: '1000000',
}],
0,
BigNumber.from(Math.floor(Date.now() / 1000)).add(1800)
]
}
]
}
```

The encode function is:

```javascript
for (let call of json.calls) {
if (call.abi != '') {
let interface = new utils.Interface([call.abi])
let funcName = call.abi.slice(9, call.abi.indexOf('('))
let data = interface.encodeFunctionData(funcName, call.params)
} else {
let data = '0x'
}
//sign the data..
}
```


## Backwards Compatibility

This EIP is backward compatible with EOA Wallet and Smart Contract Wallet.



## Copyright

Copyright and related rights waived via [CC0](../LICENSE.md).