原文标题:《 EIP-3074: Increasing Ethereum Quality of Life 》
Originally written by Maarten Zuidhoorn, Mycrypto
原文编译: 闵敏,以太坊爱好者
If you are an active user on Ethereum, there is a good chance that you hold some (ERC 20) tokens to interact with the various DEFI projects in the Ethereum ecosystem. But, if you do thatYou must hold the ETH, because ERC 20 tokens cannot be used to pay Ethereum fees. In addition, when sending tokens to a smart contract, you usually need to perform two transactions: one to license The target contract uses your token and the other one is used to transfer the token. Into the target contract.
EIP-3074 You can make smart contracts & NBSP; On behalf of & have spent An external account (that is, a plain Ethereum address) solves these and more problems by sending transactions.
EIP 3074 introduces   AUTH And & have spent AUTHCALL These two EVM directives. The first directive sets the environment variable authorized based on the ECDSA signature, and the second directive is as authorized Send the call. This essentially gives the smart contract control over external accounts.

Through & have spent AUTH And & have spent AUTHCALL EVM instructions (also known as opcodes), smart contracts can be based onSigned messageObtain authorization for an external account and send transactions on its behalf. This opens up many possibilities, such as:
· Sponsorship transactions (also known as meta-transactions): Pay gas for a transaction from another account. In this way, tokens can be sent from addresses that do not hold ETH.
· Batch transactions: Send multiple transactions through a single call. This ensures that two or more transactions are executed in the same block and can also reduce transaction fees.
· Improve user experience: For example, you can call   within a single transaction; approve And & have spent TransferFrom.
Unlike existing solutions, the EIP 3074 does not require a smart contract wallet. You can send a transaction directly to the invoker responsible for executing the transaction. The caller is a stateless trustless smart contract and does not require you to send the balance to the smart contract in advance. EIP 3074 also does not introduce new onesTransaction type. From a technical point of view, EIP 3074 should be easier to implement since only two new EVM directives are introduced.
Unfortunately, EIP 3074 is still under review, and due to various (security) concerns, it is not known when it will be activated. If you want to try it now, you can use Puxi testing. In this article, I'll detail how the EIP 3074 works.
If you want to see EIP 3074 in action, I've written a (batch) transaction caller contract as an example. Click on the link below to access:
https://github.com/Mrtenz/transaction-invoker
Please note that this contract has not been audited and is only a proof of concept. Do not use in production environment.
EIP 3074 defines two new opcodes that can be invoked by smart contracts:
· Auth (0xF6)
——
基于签名和 commit(提交)提出授权的外部账户。共有 4 个输入参数:commit 以及签名的 yParity、r 和 s。
· AuthCall (0xF7)Send the call (transaction) on behalf of an authorized external account. There are eight input parameters: gas, addr, value, valueExt, argsOffSet, argslLength, retoffSet, and retLength. With existing CALL Opcodes are similar.
Confirming the authorization of an external account requires a signed message from that external account. Call & have spent AUTH The smart contract can recover the signer from the message signature and then set it to authorized EVM environment variables. This way, the smart contract is called every time. AUTHCALL , the caller will be set to an authorized address. When the smart contract is called & NBSP; Caller (for example, via Solidity's Sender), the call will be executed by the address of the authorized external account instead of the caller's address (smart contract).
The basic flow of sending one or more transactions is shown below:

- The diagram above shows the basic flow of EIP 3074 where the caller contract sends multiple transactions.
- Authorization message signed by external account; An external account or other GAS payer sends transaction data and authorization messages to the caller contract
- The caller contract uses AUTH The opcode performs authorization and uses AUTHCALL The opcode sends the transaction.
It does not matter who is sending the transaction to the contract, as long as the signature of the external account is valid. Therefore, other people (or accounts) can also send transactions.
Please note that it is currently not possible to use EIP 3074 to send ETH through an external account. Doing so would significantly change some important current assumptions, such as checking whether a transaction is valid. The caller needs to use his/her ETH balance to send the ETH. However, you can send the ETH to the caller and have the caller send it on his behalf. At present, AUTHCALL The opcode contained in valueExt The field must be hard-coded as 0. In the future, if an appropriate solution is found, we can change this field to allow the caller external account to send ETH.
To perform authorization, the external account must sign a message in a specific format:
0x03 || < Padded invoker address> || < Commit>
(note: | | & have spent Used as a byte join operator.
The message contains three parts: a magic byte (0x03), a 32-byte caller's address (the address that executes Authorize's smart contract), and a 32-byte COMMIT.

- Authorization message format, including a COMMIT example -
This Commit describes the data committed by the external account and can be calculated based on some of the attributes of the call, such as the address, value, and hash of the nonce. The caller contract can recalculate the COMMIT from the attributes, and if these fields are correct, the authorization is performed.
Suppose we want to send the following transaction (in JSON format) :
[
{
"to": "0x6b175474e89094c44da98b954eedeac495271d0f",
"value": 123,
"nonce": 0
},
{
"to": "0x4bbeEB066eD09B7AEd07bF39EEe0460DFa261520",
"value: 123,
"nonce": 1
}
]We can hash these fields (for example, concatenate them in a deterministic way, or use EIP 712 And use the resulting hash value as a COMMIT.
We can provide signatures for the transaction and authorization messages to be sent in a smart contract, as shown in the JSON data. The contract function is shown in the following example:
function sendTransactions(Transaction[] calldata transactions, Signature calldata signature) external;
The smart contract is based on &NBSP; transactions Recalculate the COMMIT and supply the COMMIT (along with the signature) to the AUTH call. The purpose of this is to retrieve the signer's address. If the computed COMMIT is invalid, the address retrieved from the signature will be incorrect, meaning the transaction will fail.
The caller is fully responsible for the security of the Commit. You can take 0x0 Signs the message as a Commit and grants the smart contract full access to the external account. Previous versions of EIP-3074 had stricter formatting requirements for the COMMIT, including replay protection, but this has since been removed for flexibility. This requires you to trust the caller when you interact with him or her.
Because of the ability to change based on the signature; Caller, EIP 3074 dramatically changes the way EVM works. This would introduce potential loopholes for new and existing contracts. As a result,EIP 3074 has been formally audited.
Some of the safety concerns are explained below. For a variety of reasons, EIP 3074 recommends only interacting with trusted callers.MyCrypto The wallet interface provides a trusted caller whitelist function. Users using this feature can only sign authorization messages for callers on the whitelist.
As explained above, EIP 3074 does not define a standard format for the COMMIT. The caller can generate a COMMIT in any way. This means that it is the caller's responsibility to ensure the security of the Commit, for example, against replay attacks.
If the Commit does not contain some kind of random number, the attacker can easily take the signed message and send it to the caller again. The malicious caller does not need to verify the COMMIT at all to gain control of the external account. Be careful every time you sign a message.
EIP 3074 provides the most basic replay attack protection by including the caller's address in the authorization message. In this way, malicious callers cannot replay authorization messages from other callers.
EIP 3074 explicitly states that the caller program is not upgradeable. If the caller program is upgradable, an attacker can deploy another version of the caller to grant the contract control over the external account without verifying the COMMIT.
Currently, smart contracts can be used. require(tx.origin == msg.sender) To verify that the transaction came from an external account (and not another contract). This protects against reentrant attacks to some extent because it prevents the contract from calling the function.
EIP 3074 also allows &NBSP; tx.origin Become the signer of the authorization message. Any executed by the caller; AUTHCALL Will lead to tx.origin == msg.sender True, even if the call is performed by a smart contract and is therefore vulnerable to a reentrant attack. EIP 3074 states: "... the authors of this EIP could not find any examples of such a reentrant attack, although no exhaustive search was conducted."
EIP 3074 opens up many new possibilities for Ethereum. AUTH And & have spent AUTHCALL Enables external accounts to grant control of the account to smart contract callers, enabling new transaction types such as batch and sponsored transactions. However, the EIP also dramatically changes the way transactions operate on Ethereum, so we need to think more deeply about security before activating the EIP on the mainnet.
Welcome to join the official BlockBeats community:
Telegram Subscription Group: https://t.me/theblockbeats
Telegram Discussion Group: https://t.me/BlockBeats_App
Official Twitter Account: https://twitter.com/BlockBeatsAsia