Skip to content

[Bug]: Cannot handle URI Scheme with Metadata, Value and Bytecode, ERC-681 #8308

@0xPuddi

Description

@0xPuddi

Describe the bug

The QR can be generated with any library you wish, the Deep Link String is:

ethereum:0x4758aCF2d393A0f011C603eAfC9B4769322b2a94@43113/BetGame?bytes32=0x3863e63da67d85dcffede3cace2ebcbb39e67df5f6fdaf6437319cbe68cc3b94&bytes32=0x0fbf1ff35ca8785e1812f7745b1332b4b9b3c64ccd769f19869170beb4e4f513&value=1.0e15

The contract is deployed (0x4758aCF2d393A0f011C603eAfC9B4769322b2a94) on the Avalanche Fuji Testnet (ID: 43113) and it has a BetGame function that is payable and that takes two bytes32 as input. Function definition:

/**
* BetGame accetps and registers a player's game bet
*/
function BetGame(bytes32 gameId, bytes32 playerId) external payable minBet returns (bool) {
address caller = _msgSender();
uint256 betAmount = msg.value;

    // if firts game make him start it
    if (!getActiveGame(gameId)) {
        emit GameStarted(gameId, playerId, caller, betAmount, block.timestamp);
    }

    // Already in
    if (playerAddress[playerId] != address(0)) {
        revert BetAlreadyPlaced(caller, playerGameBalance[playerId][caller]);
    }

    gamePlayersIds[gameId].push(playerId);
    gameBalance[gameId] += betAmount;
    playerAddress[playerId] = caller;
    playerGameBalance[playerId][caller] = betAmount;
    emit PlayerBet(gameId, playerId, caller, betAmount, block.timestamp);
    return true;
}

/**
 * getActiveGame reutrns true is a game is active
 */
function getActiveGame(bytes32 gameId) public view returns (bool) {
    if (gamePlayersIds[gameId].length > 0) {
        return true;
    }

    return false;
}

The MetaMask Wallet reads the URL, and creates a transaction, yet the gas is miscalculated. Miscalculation of gas is probably a consequence that when you try to send the transaction it fails.

The error is a "Transaction error Internal JSON-RPC error." I tried changing also the RPC endpoint multiple times with different providers and I get the same error. Sending native coin around works.

If it can help: The value to send is correct, the chain is correct, the only problem there is is that the calldata with the function signature and input data is wrong, or not even there at all.

Expected behavior

  1. Read the QR Code

  2. Generate a transaction:

On the cainId: 43113
To: 0x4758aCF2d393A0f011C603eAfC9B4769322b2a94
With function signature: BetGame
With Input data: bytes32=0x3863e63da67d85dcffede3cace2ebcbb39e67df5f6fdaf6437319cbe68cc3b94 and bytes32=0x0fbf1ff35ca8785e1812f7745b1332b4b9b3c64ccd769f19869170beb4e4f513
And value sent of 1.0e15

  1. Send the transaction and notify on confirmation.

Screenshots/Recordings

No response

Steps to reproduce

Use the Deep Link string:

ethereum:0x4758aCF2d393A0f011C603eAfC9B4769322b2a94@43113/BetGame?bytes32=0x3863e63da67d85dcffede3cace2ebcbb39e67df5f6fdaf6437319cbe68cc3b94&bytes32=0x0fbf1ff35ca8785e1812f7745b1332b4b9b3c64ccd769f19869170beb4e4f513&value=1.0e15

Choose your favourite QR code generation method (Attached a QR code generated from Brave Browser with QR code feature. The String is the Deep Link string just mentioned above
33ca327c520c47e0a0ca681fa0bb0d41720e35cc
).

Have some gas on Avalanche Fuji Testner.

Generate the QR.

Scan the QR with MetaMask Mobile.

Error messages or log output

Internal JSON-RCP Error popup.

Version

MetaMask v7.12.3 (1230)

Build type

None

Device

Iphone XR

Operating system

iOS

Additional context

No response

Severity

Critical to all MetaMask users and developers.

The problem is that some apps functionality might not work as expected, since the ERC is finalised and well accepted developers should be able to interact using the standard without any problems or drawbacks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Sev2-normalAn issue that may lead to users misunderstanding some limited risks they are takingexternal-contributorteam-confirmationsPush issues to confirmations teamtype-bugSomething isn't working

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions