# EIP-1271

### What is EIP-1271?

EIP-1271 is an Ethereum Improvement Proposal that specifies a standard interface for contracts that can verify whether a given message or transaction is valid or not. This interface can be used to implement a kind of signature verification for smart contracts, where the contract can check if a signature is valid before executing a certain action.

To use EIP-1271 with a smart contract, you need to implement the interface defined in the proposal. The interface consists of a single function, called isValidSignature, which takes two arguments:

```solidity
function isValidSignature( bytes32 _messageHash, bytes memory _signature ) 
public view returns (bytes4);
```

The \_messageHash argument is the hash of the message or transaction that you want to verify. The \_signature argument is the signature itself, which is usually a combination of the signer's public key and some cryptographic information. The function returns a four-byte code that indicates whether the signature is valid or not.

The four-byte code is defined as follows:

* 0x00000000 if the signature is invalid.
* 0x20c13b0b if the signature is valid and was produced using the eth\_sign method.
* 0x1626ba7e if the signature is valid and was produced using the personal\_sign method.
* 0x01ffc9a7 if the signature is valid and was produced using the eth\_signTypedData method.

To implement the interface, you need to write a function that takes the \_messageHash and \_signature arguments and returns one of the four-byte codes described above. The function should use cryptographic functions to verify the signature and return the appropriate code.

Once you have implemented the interface, you can use the isValidSignature function in your smart contract to check whether a given signature is valid or not. For example, you could use it to verify that a user has signed a message before allowing them to perform a certain action in your contract.

Overall, EIP-1271 provides a standard way for smart contracts to verify signatures and ensure that only authorized parties can perform certain actions. By implementing the interface, you can add an extra layer of security to your smart contract and prevent unauthorized access or malicious behavior.

### Why is EIP-1271 important for the future of Ethereum?

Smart contracts cannot directly sign messages, so EIP-1271 serves as a guide to implement isValidSignature(hash, signature) on the signing contract that can be called to validate a signature.&#x20;

With the rise of smart contract wallets and DAOs controlled by multi-sigs these parties require the means to use signed messages to demonstrate the right to move assets, vote, or for other purposes. EIP-1271 is, additionally, the foundation for account abstraction which enables the evolution of the Ethereum ecosystem.

### What kind of dApps is EIP-1271 important for?

Any dApp which would like to implement AA features that simplify UX and boost its capabilities should implement EIP-1271.

### How do I implement EIP-1271 on my smart contract?

You can use our npm package that makes it easy for dapps to add support for EIP 1271.&#x20;

`npm install @etherspot/eip1271-verification-util`\
\
You can also take a look at example code [in this repo.](https://github.com/etherspot/eip1271-verification-util/)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://v1.etherspot.io/reference/eip-1271.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
