Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Authenticators in python v2 client #320

Closed
konichuvak opened this issue Feb 1, 2025 · 2 comments
Closed

Authenticators in python v2 client #320

konichuvak opened this issue Feb 1, 2025 · 2 comments

Comments

@konichuvak
Copy link

Hi team, any plans on supporting authenticators for enabling permissioned keys functionality?
It looks like v4-proto >=7 already has the right protobufs for it.

I upgraded protobuf==5.29, grpcio==1.70.0 and v4-proto==7.0.5 and tried with the following example, but the transaction fails with "Out Of Gas" error every time.

import asyncio
import base64
import json
import os

from dotenv import load_dotenv
from dydx_v4_client.network import make_mainnet
from dydx_v4_client.node.client import NodeClient
from dydx_v4_client.wallet import KeyPair, Wallet
from v4_proto.dydxprotocol.accountplus.tx_pb2 import MsgAddAuthenticator


load_dotenv()

NODE_URL = 'dydx-grpc.publicnode.com:443'


async def setup_key():

    # Set up a node connection to broadcast transactions to
    network = make_mainnet(
        rest_indexer='',
        websocket_indexer='',
        node_url=NODE_URL
    )
    node: NodeClient = await NodeClient.connect(network.node)

    # Set up the primary wallet for which we want to add authenticator
    wallet = await Wallet.from_mnemonic(
        node,
        mnemonic=os.environ['DYDX_MNEMONIC'],
        address=os.environ['DYDX_ADDRESS'],
    )

    # Derive the public address of the signer wallet from its private key
    key_pair = KeyPair.from_mnemonic(os.environ['DYDX_SIGNER_MNEMONIC'])
    signer_public_key = key_pair.public_key_bytes

    sub_authenticators = [
        {
            'type': 'SignatureVerification',
            'config': base64.b64encode(signer_public_key).decode(),
        },
        {
            'type': 'MessageFilter',
            'config': base64.b64encode(b'/dydxprotocol.clob.MsgPlaceOrder').decode(),
        },
    ]
    request = MsgAddAuthenticator(
        sender=wallet.address,
        authenticator_type="AllOf",
        data=json.dumps(sub_authenticators).encode(),
    )

    transaction = await node.send_message(wallet, request)
    print(transaction)


if __name__ == '__main__':
    asyncio.run(setup_key())
Copy link

linear bot commented Feb 1, 2025

@konichuvak
Copy link
Author

The solution was to bump the GAS_MULTIPLIER from 1.4 to 1.6 in the config.py.
Thanks @v0-e for the suggestion in #322

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant