broxus / everscale-inpage-provider

Web3-like interface to the Everscale blockchain.
https://broxus.github.io/everscale-inpage-provider/
GNU General Public License v3.0
30 stars 17 forks source link

Sender not found #15

Closed cypherslopps closed 9 months ago

cypherslopps commented 9 months ago

I get this error (Error: sendMessage: Sender not found) when i attempt to send tokens to a recipient address:

` const tokenWalletAddress = new Address(tokenWalletAddress); const tokenWalletContract = new standalone.Contract(tokenWalletAbi, contractAddress);

await tokenWalletContract.methods.transfer({ amount: amountOfTokens, recipient: new Address(recipientAddress), deployWalletValue: "1000000000", remainingGasTo: new Address(address), notify: true, payload: "" }).send({ from: new Address(address), amount: "1000000000", bounce: true });`

Rexagon commented 9 months ago

If you are trying to send this transfer from the browser, make sure that the sender is an address of the connected account. It should look something like this:

const provider = new ProviderRpcClient();

const { accountInteraction } = await ever.requestPermissions({
  permissions: ['basic', 'accountInteraction'],
});
if (accountInteraction == null) {
  throw new Error('Insufficient permissions');
}

const address = accountInteraction.address;
...

Or if you are using an everscale-standalone-client from nodejs, then you need to make sure that the sender address is from the account that was added to the account storage. Like this:

import {
  EverscaleStandaloneClient,
  SimpleAccountsStorage,
  EverWalletAccount,
  SimpleKeystore,
} from "everscale-standalone-client";

...
const someKeypair = SimpleKeystore.generateKeyPair(); // or import it from somewhere
const account = await EverWalletAccount.fromPubkey({
  publicKey: someKeypair.publicKey,
});

const keystore = new SimpleKeystore();
keystore.addKeyPair(someKeypair);

const accountsStorage = new SimpleAccountsStorage();
const address = accountsStorage.addAccount(account);

const provider = new ProviderRpcClient({
  forceUseFallback: true,
  fallback: () =>
    EverscaleStandaloneClient.create({
      accountsStorage,
      keystore,
      ...
    }),
});

...

You can also look at the corresponding section in the guide - https://provider-docs.broxus.com/guides/installation.html#permissions

cypherslopps commented 9 months ago

Thanks

If you are trying to send this transfer from the browser, make sure that the sender is an address of the connected account. It should look something like this:

const provider = new ProviderRpcClient();

const { accountInteraction } = await ever.requestPermissions({
  permissions: ['basic', 'accountInteraction'],
});
if (accountInteraction == null) {
  throw new Error('Insufficient permissions');
}

const address = accountInteraction.address;
...

Or if you are using an everscale-standalone-client from nodejs, then you need to make sure that the sender address is from the account that was added to the account storage. Like this:

import {
  EverscaleStandaloneClient,
  SimpleAccountsStorage,
  EverWalletAccount,
  SimpleKeystore,
} from "everscale-standalone-client";

...
const someKeypair = SimpleKeystore.generateKeyPair(); // or import it from somewhere
const account = await EverWalletAccount.fromPubkey({
  publicKey: someKeypair.publicKey,
});

const keystore = new SimpleKeystore();
keystore.addKeyPair(someKeypair);

const accountsStorage = new SimpleAccountsStorage();
const address = accountsStorage.addAccount(account);

const provider = new ProviderRpcClient({
  forceUseFallback: true,
  fallback: () =>
    EverscaleStandaloneClient.create({
      accountsStorage,
      keystore,
      ...
    }),
});

...

You can also look at the corresponding section in the guide - https://provider-docs.broxus.com/guides/installation.html#permissions

Thanks alot @Rexagon, i've fixed the error but my venon wallet doesn't pop up when i try sending a selected token from it's token wallet to a recipient address. It works for my venom testnet tokens but doesn't work for my other tokens in my wallet . This is my code:

`
/ Numi Shards Token Root Address / const tokenRootContractAddress = new Address("0:c45801ac28c32ffcea225450cb6c1b94686115d6b74787feb9c6d5701cb84399"); const tokenRootContract = new standalone.Contract(tokenRootAbi, tokenRootContractAddress);

  const tokenWallet = (await tokenRootContract.methods.walletOf({
    answerId: 0,
    walletOwner: wallet
  }).call());

  if(!tokenWallet) return undefined;

  const contractAddress = new Address(tokenWallet.value0._address);
  const contract = new standalone.Contract(tokenWalletAbi, contractAddress);

  const receipt = await tokenWalletContract.methods.transfer({
        amount: "1000000000",
        recipient: new Address(recipientAddress),
        deployWalletValue: 0,
        remainingGasTo: new Address(userAddress),
        notify: true,
        payload: ""
      }).send({
        from: new Address(userAddress),
        amount: "1000000000",
        bounce: true
      });

`

Rexagon commented 9 months ago

Are there any errors during sending attempts? And does the promise even resolve?

cypherslopps commented 9 months ago

There are no errors, and the promise resolves. My venom wallet doesn't pop up when i use this (My tokens e.g. Shiba Inu, Nomi etc.): const receipt = await tokenWalletContract.methods.transfer({ amount: amountOfTokens, recipient: new Address(recipientAddress), deployWalletValue: 0, remainingGasTo: new Address(address), notify: true, payload: "" }).send({ from: new Address(address), amount: "1000000000", bounce: true }); but works when for this (Venom Testnet): const { transaction } = await venomProvider.sendMessage({ sender: new Address(address), recipient: new Address(recipientAddress), amount: "1000000000", bounce: true, payload: "" }); .

This is my Github venom repo for venom config and the token transfer implementation: https://github.com/cypherslopps/venom-dapp