Skip to content

ERC20 Asset Transactor#7762

Merged
franciscoaguirre merged 83 commits intomasterfrom
erc20-transactor
May 28, 2025
Merged

ERC20 Asset Transactor#7762
franciscoaguirre merged 83 commits intomasterfrom
erc20-transactor

Conversation

@franciscoaguirre
Copy link
Copy Markdown
Contributor

@franciscoaguirre franciscoaguirre commented Feb 28, 2025

Partially addresses #7523.

In order to interact with ERC20 tokens via XCM (with DepositAsset, WithdrawAsset instructions), we need an Asset Transactor that can match them and call their contracts.

I originally implemented the fungibles::* family of traits for pallet-revive in order to reuse the FungiblesAdapter.
This was not suitable for the final solution since the adapter doesn't let you return fees to do anything with them.

For getting the fees to work, I had to implement TransactAsset manually. I left the fungibles::* implementation for useful inspecting and minting in tests.

A standard ERC20 transfer costs a specific amount of gas. We use this as the gas limit for every WithdrawAsset or DepositAsset in the executor. We call this GasLimit.

I implemented a new method in TransactAsset that returns the surplus, GasLimit - gas_consumed.
I managed to make it non-breaking by making this new function have a default implementation that calls the normal function and adds Weight::zero() to the return value.

@franciscoaguirre franciscoaguirre added T6-XCM This PR/Issue is related to XCM. T7-smart_contracts This PR/Issue is related to smart contracts. labels Mar 13, 2025
@franciscoaguirre franciscoaguirre force-pushed the erc20-transactor branch 2 times, most recently from ea920e9 to 9951075 Compare May 8, 2025 16:14
@franciscoaguirre franciscoaguirre marked this pull request as ready for review May 11, 2025 23:02
@franciscoaguirre franciscoaguirre requested a review from a team as a code owner May 11, 2025 23:02
Comment on lines +450 to +452
ext.execute_with(|| {
assert_ok!(Pallet::<Test>::map_account(RuntimeOrigin::signed(checking_account)));
});
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure I mean since you use the genesis config for the balance you can also use pallet_revive geneis config to set the mapping

@paritytech-workflow-stopper
Copy link
Copy Markdown

All GitHub workflows were cancelled due to failure one of the required jobs.
Failed workflow url: https://github.com/paritytech/polkadot-sdk/actions/runs/15307326616
Failed job name: test-linux-stable

@franciscoaguirre franciscoaguirre added this pull request to the merge queue May 28, 2025
Merged via the queue into master with commit 2d966e9 May 28, 2025
180 of 181 checks passed
@franciscoaguirre franciscoaguirre deleted the erc20-transactor branch May 28, 2025 22:29
@github-project-automation github-project-automation bot moved this from To be released (SDK) to Integrated - Done in fellowship/runtimes integrations queue May 28, 2025
@bkontur bkontur moved this from Integrated - Done to To be released (SDK) in fellowship/runtimes integrations queue May 29, 2025
pgherveou added a commit that referenced this pull request Jun 11, 2025
Shared PR that adds ethereum-standards crate used by upcoming #7762 and
#8365

---------

Co-authored-by: cmd[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Francisco Aguirre <franciscoaguirreperez@gmail.com>
pgherveou pushed a commit that referenced this pull request Jun 11, 2025
Partially addresses
#7523.

In order to interact with ERC20 tokens via XCM (with `DepositAsset`,
`WithdrawAsset` instructions), we need an Asset Transactor that can
match them and call their contracts.

I originally implemented the `fungibles::*` family of traits for
`pallet-revive` in order to reuse the `FungiblesAdapter`.
This was not suitable for the final solution since the adapter doesn't
let you return fees to do anything with them.

For getting the fees to work, I had to implement `TransactAsset`
manually. I left the `fungibles::*` implementation for useful inspecting
and minting in tests.

A standard ERC20 transfer costs a specific amount of gas. We use this as
the gas limit for every `WithdrawAsset` or `DepositAsset` in the
executor. We call this `GasLimit`.

I implemented a new method in `TransactAsset` that returns the surplus,
`GasLimit - gas_consumed`.
I managed to make it non-breaking by making this new function have a
default implementation that calls the normal function and adds
`Weight::zero()` to the return value.

---------

Co-authored-by: Adrian Catangiu <adrian@parity.io>
Co-authored-by: Alexander Theißen <alex.theissen@me.com>
This was referenced Sep 28, 2025
alvicsam pushed a commit that referenced this pull request Oct 17, 2025
Shared PR that adds ethereum-standards crate used by upcoming #7762 and
#8365

---------

Co-authored-by: cmd[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Francisco Aguirre <franciscoaguirreperez@gmail.com>
alvicsam pushed a commit that referenced this pull request Oct 17, 2025
Partially addresses
#7523.

In order to interact with ERC20 tokens via XCM (with `DepositAsset`,
`WithdrawAsset` instructions), we need an Asset Transactor that can
match them and call their contracts.

I originally implemented the `fungibles::*` family of traits for
`pallet-revive` in order to reuse the `FungiblesAdapter`.
This was not suitable for the final solution since the adapter doesn't
let you return fees to do anything with them.

For getting the fees to work, I had to implement `TransactAsset`
manually. I left the `fungibles::*` implementation for useful inspecting
and minting in tests.

A standard ERC20 transfer costs a specific amount of gas. We use this as
the gas limit for every `WithdrawAsset` or `DepositAsset` in the
executor. We call this `GasLimit`.

I implemented a new method in `TransactAsset` that returns the surplus,
`GasLimit - gas_consumed`.
I managed to make it non-breaking by making this new function have a
default implementation that calls the normal function and adds
`Weight::zero()` to the return value.

---------

Co-authored-by: Adrian Catangiu <adrian@parity.io>
Co-authored-by: Alexander Theißen <alex.theissen@me.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

T6-XCM This PR/Issue is related to XCM. T7-smart_contracts This PR/Issue is related to smart contracts.

Projects

Status: Done
Status: To be released (SDK)

Development

Successfully merging this pull request may close these issues.

7 participants