coinbase / waas-sdk-react-native

Coinbase Wallet as a Service (WaaS) SDK for React Native. Enables MPC Operations for iOS and Android Devices.
https://docs.cloud.coinbase.com/waas
Other
234 stars 104 forks source link

Facing issues while genarating signature that could interact with smart contract #28

Closed SyedImam1998 closed 6 months ago

SyedImam1998 commented 1 year ago

Hi Team,

I am trying generate a signed tx that would change the state of the smart contract but not sure why i am not able to generate signed transaction.

I am Getting this Error:

[Error: error getting RLP transaction in CreateTxSignature: invalid value ]

Smart Contract: 0x28983feD81de3548d2e4C110BCB997A4879dA478 - This is the smart contract that i trying to interact deployed on Goerli Test Network.

Below is my React-Native code:

const setNameFunc = async () => {
    const setNameFunction = contract.interface.getFunction('setName');
    const setNameTransactionData = contract.interface.encodeFunctionData(setNameFunction,['John Doe']);
    const cleanedAddress = addressName.replace('networks/ethereum-goerli/addresses/','',);
    const nonce = await provider.getTransactionCount(cleanedAddress);
    const gasInfo = await provider.getFeeData();
    const initialTx = {
      ChainID: '0x5',
      Nonce: nonce,
      MaxPriorityFeePerGas: gasInfo.maxPriorityFeePerGas?.toHexString(),
      MaxFeePerGas: gasInfo.maxFeePerGas?.toHexString(),
      Gas: 21000,
      To: '0x28983feD81de3548d2e4C110BCB997A4879dA478',
      Data: setNameTransactionData,
      Value: '',
    };
    Signtx(initialTx);
  };
const Signtx = async (initialTx: any) => {
    try {
      console.log('started');
      await initMPCSdk(true);
      await initMPCKeyService(apiKeyName, privateKey);
      await initMPCWalletService(apiKeyName, privateKey);
      const retrievedAddress = await getAddress(addressName);
      const keyName = retrievedAddress.MPCKeys[0]!;
      const resultTx = initialTx as Transaction;
      await createSignatureFromTx(keyName, resultTx);
      const pendingSignatures = await pollForPendingSignatures(deviceGroupName);
      await computeMPCOperation(pendingSignatures[0]!.MPCData);
      let signatureResult = await waitPendingSignature(
        pendingSignatures[0]!.Operation,
      );
      const signedTxResult = await getSignedTransaction(
        resultTx,
        signatureResult,
      );
      setSignedTx(signedTxResult);
      const txReceipt = await provider.sendTransaction(
        signedTxResult.RawTransaction,
      );
      console.log('Transaction hash:', txReceipt.hash);
    } catch (error) {
      console.log('error');
      console.log(error);
      throw new Error('Invalid initialTx value');
    }
  };

Can someone please help me here.

wadeleet commented 1 year ago

go

Kapiorek888 commented 1 year ago

const Signtx = async (initialTx: any) => { try { console.log('started'); await initMPCSdk(true); await initMPCKeyService(apiKeyName, privateKey); await initMPCWalletService(apiKeyName, privateKey); const retrievedAddress = await getAddress(addressName); const keyName = retrievedAddress.MPCKeys[0]!; const resultTx = initialTx as Transaction; await createSignatureFromTx(keyName, resultTx); const pendingSignatures = await pollForPendingSignatures(deviceGroupName); await computeMPCOperation(pendingSignatures[0]!.MPCData); let signatureResult = await waitPendingSignature( pendingSignatures[0]!.Operation, ); const signedTxResult = await getSignedTransaction( resultTx, signatureResult, ); setSignedTx(signedTxResult); const txReceipt = await provider.sendTransaction( signedTxResult.RawTransaction, ); console.log('Transaction hash:', txReceipt.hash); } catch (error) { console.log('error'); console.log(error); throw new Error('Invalid initialTx value'); } };

caledrummond90 commented 8 months ago

  { "name": "organizations/4124b181-5f9d-443a-9901-b34d2b2a0dd7/apiKeys/17c8f37c-1aa4-420b-9419-c163b2346e4a", "principal": "257b9fc8-eda1-59bb-aeb0-64e92be2ccf3", "principalType": "USER", "publicKey": "-----BEGIN EC PUBLIC KEY-----\nMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEV9qY4D6xL1qIOZUW6l4EvG0DDjhI\nF5hXhQN66CydYrXORu6ZWaSfzG393/9W1xeRWdvc9kZ1mHGbJ7x6MYCJLg==\n-----END EC PUBLIC KEY-----\n", "privateKey": "-----BEGIN EC PRIVATE KEY-----\nMHcCAQEEIFTtTWAtyqpMCtVgbIK41iFnFxk7G8cDflyOtQw9ZUTWoAoGCCqGSM49\nAwEHoUQDQgAEV9qY4D6xL1qIOZUW6l4EvG0DDjhIF5hXhQN66CydYrXORu6ZWaSf\nzG393/9W1xeRWdvc9kZ1mHGbJ7x6MYCJLg==\n-----END EC PRIVATE KEY-----\n", "createTime": "2024-01-05T18:57:05.666163829Z", "projectId": "20a8cc65-aca5-4b91-bfbc-331ceffff2fb", "nickname": "cloud-project-2-key-20240105185700826Z", "scopes": [], "allowedIps": [], "keyType": "GENERAL_KEY", "enabled": true

Silvrbckw commented 8 months ago

Why are you sending me your private keys

On Fri, Jan 5, 2024, 1:59 PM caledrummond90 @.***> wrote:

{ "name": "organizations/4124b181-5f9d-443a-9901-b34d2b2a0dd7/apiKeys/17c8f37c-1aa4-420b-9419-c163b2346e4a", "principal": "257b9fc8-eda1-59bb-aeb0-64e92be2ccf3", "principalType": "USER", "publicKey": "-----BEGIN EC PUBLIC KEY-----\nMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEV9qY4D6xL1qIOZUW6l4EvG0DDjhI\nF5hXhQN66CydYrXORu6ZWaSfzG393/9W1xeRWdvc9kZ1mHGbJ7x6MYCJLg==\n-----END EC PUBLIC KEY-----\n", "privateKey": "-----BEGIN EC PRIVATE KEY-----\nMHcCAQEEIFTtTWAtyqpMCtVgbIK41iFnFxk7G8cDflyOtQw9ZUTWoAoGCCqGSM49\nAwEHoUQDQgAEV9qY4D6xL1qIOZUW6l4EvG0DDjhIF5hXhQN66CydYrXORu6ZWaSf\nzG393/9W1xeRWdvc9kZ1mHGbJ7x6MYCJLg==\n-----END EC PRIVATE KEY-----\n", "createTime": "2024-01-05T18:57:05.666163829Z", "projectId": "20a8cc65-aca5-4b91-bfbc-331ceffff2fb", "nickname": "cloud-project-2-key-20240105185700826Z", "scopes": [], "allowedIps": [], "keyType": "GENERAL_KEY", "enabled": true

— Reply to this email directly, view it on GitHub https://github.com/coinbase/waas-sdk-react-native/issues/28#issuecomment-1879129387, or unsubscribe https://github.com/notifications/unsubscribe-auth/A47JDC5Y7GDLY44WD6LFYJLYNBEQRAVCNFSM6AAAAAAXYH2REOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNZZGEZDSMZYG4 . You are receiving this because you are subscribed to this thread.Message ID: @.***>

DanielaDudyova commented 6 months ago

Can you accept my invite, and help me get my gift? Just download the SHEIN app, and search for my code there! ebgjq9