Add EVM function to reclaim ERC20 tokens from attacker's EOA addresses#8293
Merged
Add EVM function to reclaim ERC20 tokens from attacker's EOA addresses#8293
Conversation
Contributor
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Collaborator
Author
|
Tx to reclaim import EVM from 0xe467b9dd11fa00df
import FlowServiceAccount from 0xe467b9dd11fa00df
transaction(from: String, to: String, amount: UInt256) {
let flowServiceAccountAdmin: &FlowServiceAccount.Administrator
prepare(signer: auth(BorrowValue) &Account) {
self.flowServiceAccountAdmin = signer.storage.borrow<&FlowServiceAccount.Administrator>(
from: /storage/flowServiceAdmin
) ?? panic("Unable to borrow reference to administrator resource")
}
execute {
let usdfContractAddress: String = "0x2aaBea2058b5aC2D339b163C6Ab6f2b6d53aabED"
let toAddress: EVM.EVMAddress = EVM.addressFromString(to)
let transferCallData: [UInt8] = EVM.encodeABIWithSignature(
"transfer(address,uint256)",
[toAddress, amount]
)
let txResult = self.flowServiceAccountAdmin.reclaimERC20FromAttackerEOAs(
from: from,
to: usdfContractAddress,
data: transferCallData
)
assert(
txResult.status == EVM.Status.successful,
message: "evm_error=\(txResult.errorMessage);evm_error_code=\(txResult.errorCode)"
)
}
}Tx to reclaim import EVM from 0xe467b9dd11fa00df
import FlowServiceAccount from 0xe467b9dd11fa00df
transaction(from: String, to: String, amount: UInt256) {
let flowServiceAccountAdmin: &FlowServiceAccount.Administrator
prepare(signer: auth(BorrowValue) &Account) {
self.flowServiceAccountAdmin = signer.storage.borrow<&FlowServiceAccount.Administrator>(
from: /storage/flowServiceAdmin
) ?? panic("Unable to borrow reference to administrator resource")
}
execute {
let trumpContractAddress: String = "0xD3378b419feae4e3A4Bb4f3349DBa43a1B511760"
let toAddress: EVM.EVMAddress = EVM.addressFromString(to)
let approveCallData: [UInt8] = EVM.encodeABIWithSignature(
"approve(address,uint256)",
[toAddress, amount]
)
var txResult = self.flowServiceAccountAdmin.reclaimERC20FromAttackerEOAs(
from: from,
to: trumpContractAddress,
data: approveCallData
)
assert(
txResult.status == EVM.Status.successful,
message: "evm_error=\(txResult.errorMessage);evm_error_code=\(txResult.errorCode)"
)
let transferCallData: [UInt8] = EVM.encodeABIWithSignature(
"transfer(address,uint256)",
[toAddress, amount]
)
txResult = self.flowServiceAccountAdmin.reclaimERC20FromAttackerEOAs(
from: from,
to: trumpContractAddress,
data: transferCallData
)
assert(
txResult.status == EVM.Status.successful,
message: "evm_error=\(txResult.errorMessage);evm_error_code=\(txResult.errorCode)"
)
}
} |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
janezpodhostnik
approved these changes
Jan 5, 2026
zhangchiqing
approved these changes
Jan 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Depends on: onflow/flow-core-contracts#573
Necessary change to reclaim ERC20 tokens from the attacker's EOA addresses:
After we perform this last reclamation process, we can revert all changes to
EVM&FlowServiceAccountcontracts.