đŸ’ģSCW SDKs <> Banana

Banana offers a solution to streamline the user experience of smart contract wallets by providing an SDK that simplifies the authentication process. Banana's SDK offers a more user-friendly and web2-native authentication method through passkeys. With Banana's solution, users can create a wallet in under 40 seconds without the hassle of managing seed phrases or private keys. This approach aims to make using smart contract wallets more accessible to a wider audience by reducing the complexity of the onboarding process.

Changes in smart contracts

One of the major changes is to include the verification logic of the secp256r1 signature. For more information on this read here. A state variable for showing the public keys will be added in SCW.

/**
* Verification call
* @param userOp the user operation to validate.
* @param signature this is a combined signature with r, s, hashedMessage and clientDataJsonHash
* @param userOpHash hash of the userOp sent
* @param qValues public key of passkey
*/
interface IBananaVerificationModule{
	function verify(bytes memory signature, bytes32 userOpHash, uint256[2] memory qValues)
	external returns(bool success)
}
//q values for the elliptic curve representing the public key of the user
uint256[2] qValues;

Banana has already exposed a contract for providing checks for both checking that correct userOp is passed with this current signature and that the signature is valid.

In validateSignature in Smart contract wallets:

function _validateSignature(
        UserOperation calldata userOp,
        bytes32 userOpHash
    ) internal virtual returns (uint256 validationData) {
	bool success = IBananaVerificationModule(DEPLOYED_ADDRESS).verify(userOp.singature, userOpHash, qValues);
       
        if (!success) return SIG_VALIDATION_FAILED;
        return 0;
    }

As the changes on the SDK side of wallets will vary they cannot be explicitly mentioned. But some common changes which all the SDKs need to implement are discussed below.

Banana Wallet SDK usage flow

  • To initiate an instance of the Banana class in the Banana SDK, the developer must provide a network ID during initialization, which will serve as the default network for the user's smart contract wallet deployment. The Banana class contains all the necessary utility functions and methods to facilitate the creation and connection of smart contract wallets.

  • After creating an instance of the Banana class through Banana SDK, developers can use the createWallet method to create a smart contract wallet for the user. The createWallet method takes a unique wallet identifier or wallet name as input and returns a wallet instance. The wallet instance generated by Banana currently has a 1:1 mapping between the wallet and the account. Users can access their wallet later on using the unique wallet identifier or wallet username provided during the creation process.

  • When a user creates a new wallet using Banana SDK, some wallet metadata (public information) is cached in the user's cookie storage to allow faster connection to the already-created wallet. This caching mechanism helps to improve the user experience by reducing the time taken to access the wallet.

  • To retrieve the name of an already created wallet, developers can use the getWalletName method of the Banana instance which fetches the wallet name from cookie storage. To connect to the previously created wallet, developers can pass the retrieved wallet name to the connectWallet method of the Banana instance. This method returns the wallet instance of the same wallet previously created by the user.

If you have any questions please post them Banana SDK Discord forum.

Last updated