1. I want to create a contract.
  2. I want to generate a QR code to invoke this contract.
  3. I want to present this QR code to a user.

Is there a way to embed any additional information into the QR code (like username or seed or any other small piece of data)? In other words, I want to pass some values into contract by encoding it into QR code. Each generated QR code would look different, but invoke the same contract.

Thank you!


You invoke the same contract via the to address field using a transaction. You can add data using the data field.

QR codes can be generated for any data. They can get quite large and detailed for larger data sets but we at MyEtherWallet successfully use QR codes to move signed transaction from an offline computer to an online one on the offline transaction tab.

Note: QR codes do have a maximum size. Numeric only: 7,089 characters. Alphanumeric: 4,296 characters. Binary/byte: 2,953 characters (8-bit bytes). You can learn more here.

So, the question comes down to: what information do you want to put in the QR code, and what does the user do?

Here is one solution:

  1. Find platform that accepts parameters for a contract via query strings or another method.

  2. Generate a URI with those parameters for the user and turn it into a QR code.

  3. Invite the user to use the QR code to arrive at that URL and use their account to make the transaction (aka interact with the smart contract)

Let's take an example of how you could do it, right now, using MyEtherWallet, which has the ability to accept to address, amount, data, and gas on the send transaction page.

Let's say you want to have a user send 1 ETH to the address 0x7cB57B5A97eAbe94205C07890BE4c1aD31E486A8 with a simple text string, and a slight increase in gas to 23000 to cover the cost of the extra data. The URL you would start with would be:


If a user were to go to that tab and unlock their account they would have all that information filled out. Then they just have to generate the signed transaction and send it off. If you wish to test and see what happens when you go to that URL, you can use test priv key of 92aa647439f9300d214f9264141931627082364f4c081a646d72e067e04e0e1b to unlock the wallet and see.

Data can be whatever you want and that is a separate issue that you must deal with. All data must be in hex format. In the above example I used an online ascii to hex converter to send the message "MyEtherWallet is the best!" In this case, the receiving address doesn't do anything with that data. Obviously if the receiving address was a contract, it could be set up to read and do something with it based on the value of that data.

| improve this answer | |
  • I didn't know MEW could handle this type of url. Nice work ! Keep coding ! – Nicolas Massart Jun 9 '16 at 18:13
  • 1
    One benefit of not having to open a discussion about potential dangers of URIs. I'm sure that EIP will go through...at some point. 😣 – tayvano Jun 9 '16 at 20:20

You should look at Alex Van De Sand proposal for ERC url from EIP (Ethereum Improvement Proposals) project that aims to create a system to enable apps to fill a transaction, including the data field. Data field is what you need to fill to call a contract function. Once you have this URL string, you will only have to generate a QRCode for it.

This proposal is inspired by BIP 21 and could apply to IBAN address format but can be extended to other proposed addresses formats. Imagine these scenarios:

  • An exchange or a instant converter like shape shift wants to create a single ethereum address for payments that will be converted into credit in their internal system or output bitcoin to an address

  • A store wants to show a QR code to a client that will pop up a payment for exactly 12.34 ethers, which contains metadata on the product being bought

  • A betting site wants to provide a link that the user can click on his site and it will open a default ethereum wallet and and execute a specific contract with given parameters

  • A dapp in Mist wants so simply ask the user to sign a transaction with a specific abi in a single call

But as far as I know, no mobile wallet can call arbitrary contract for now (I bet that the first to give this possibility will be Jaxx as they work very hard to improve their wallet) and this proposal is still not adopted and implemented neither in mobile and desktop wallets.

| improve this answer | |

"Of course you can", in theory and with practice. You can use this technique.

If you have the patience to watch it entirely, a detailed explanation can be found in this video.

| improve this answer | |
  • 2
    Welcome to Ethereum! Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference. – Afr Jun 10 '16 at 8:24
  • 1
    Also even with reading the paper I don't get where you find it useful to accomplish what OP asks for. Can you explain please ? – Nicolas Massart Jun 10 '16 at 8:59
  • With steganography and compression algorithms, you can encode information in the form of binary pixels of data, without altering a working QR. The idea is to have a small picture(the data) in a QR, which can do whatever the user wants. Should I add this in the answer? – Techno.Shaman Jun 10 '16 at 12:14
  • There are many possibilities though,that should be taken as a viable example. – Techno.Shaman Jun 10 '16 at 12:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.