moonbeam icon indicating copy to clipboard operation
moonbeam copied to clipboard

Unable to use Keypair

Open dudo50 opened this issue 2 years ago • 10 comments

When I want to try registering asset on local network I receive error.

Code I want to execute in javascript section:

// Make a transfer from Alice to Bob and listen to system events. // You need to be connected to a development chain for this example to work. [const ALICE = '5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY'; const BOB = '5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty';

const call4 = api.tx.assetManager.registerForeignAsset({Xcm: {parents: 1,interior: "Here"}},{name: "UNIT",symbol: "UNIT",decimals: 12,isFrozen: "false"},0, "Yes") const result4 = await (call4).signAndSend(ALICE, (result) => { console.log(result.toHuman()) });](url)

Error I get

Uncaught error. Something went wrong with the query and rendering of this component. Please supply all the details below when logging an issue, it may help in tracing the cause.

[](Unable to retrieve keypair '0x3547727776614546357a58623236467a39726351'

Error: Unable to retrieve keypair '0x3547727776614546357a58623236467a39726351' at ye.get (https://polkadot.js.org/apps/polkadot.02.2489866d.js:1:263065) at ve.getPair (https://polkadot.js.org/apps/polkadot.02.2489866d.js:1:265727) at Ge.keyringOption.getPair (https://polkadot.js.org/apps/polkadot.02.2489866d.js:1:272943) at FW (https://polkadot.js.org/apps/main.af2838f1.js:19:165721) at https://polkadot.js.org/apps/main.af2838f1.js:19:169725 at nl (https://polkadot.js.org/apps/react.01.3d7f8d10.js:2:350449) at wc (https://polkadot.js.org/apps/react.01.3d7f8d10.js:2:370556) at sc (https://polkadot.js.org/apps/react.01.3d7f8d10.js:2:362857) at Vo (https://polkadot.js.org/apps/react.01.3d7f8d10.js:2:303918) at https://polkadot.js.org/apps/react.01.3d7f8d10.js:2:369358)

How to fix this? Thank you

dudo50 avatar Jul 09 '22 22:07 dudo50

Moonbeam is using AccointId20 as format (like Ethereum Account made of 20 bytes). You are providing an AccountId32 which is not compatible.

Alith address and private key can be found there https://github.com/PureStake/moonbeam#prefunded-development-addresses

crystalin avatar Jul 09 '22 23:07 crystalin

Is there any possibility to compile it into accountid32? I am working on xcm transfer tool and it does not allow me to transfer xcm messages to moonbream from rococo relay chain because xcm messages from rococo require account id32.. Thanks in advance

dudo50 avatar Jul 10 '22 12:07 dudo50

@dudo50 No it is not possible to compile with AccountId32 (I think there are some restrictions related to the EVM blocking it) But you can totally use XCM with AccountId20 from Rococo.

When you build the XCM message, if you want to target the Parachain Moonbeam, you can use:

Xcm: { parents: 1, interior: { X1: { Parachain: 1000} } }

(In local development, Moonbeam is 1000

If you want to target a specific AccountId20 on Moonbeam in your XCM fragment, you can specify it, See this XCM DepositAsset instruction

DepositAsset: {
  assets: { Wild: "All" },
  maxAssets: new BN(1),
  beneficiary: {
    parents: 0,
    interior: { X1: { AccountKey20: { network: "Any", key: "0xf24FF3a9CF04c71Dbc94D0b566f7A27B94566cac" } } },
  },
}

(See that we are using alith AccountId20: 0xf24FF3a9CF04c71Dbc94D0b566f7A27B94566cac)

crystalin avatar Jul 10 '22 13:07 crystalin

Thank you very much this is very important information to me! I will now start testing this. Have nice rest of the day.

dudo50 avatar Jul 10 '22 19:07 dudo50

So when tested, I receive error on Moonbeam side: outcome: XcmV2TraitsOutcome { Incomplete: [ 600,000,000 TooExpensive ] } Any idea on how to solve this? Thank you

dudo50 avatar Jul 10 '22 19:07 dudo50

@dudo50 it probably means you didn't have enough assets or didn't buy enough execution. Also, it would help that you put what message you are sending so it makes it easier for us to help

crystalin avatar Jul 10 '22 21:07 crystalin

Hi, the call I am sending is following:

const call = api.tx.xcmPallet.reserveTransferAssets({V1: { parents:0, interior:{ X1: {Parachain: destPara}}}}, {V1:{parents:0,interior:{X1:{AccountKey20: {network: "Any", key: this.addr}}}}}, {V1: [{id: {Concrete: {parents:0, interior: "Here"}}, fun:{ Fungible: this.amount}}]},0).signAndSend(keyring.createFromUri(account), (result) => { console.log(result) })

this.amount is > 1000000000000 account is address of default account in rococo this.addr is destination address

Also message leaves rococo just fine. Thanks in advance

dudo50 avatar Jul 12 '22 05:07 dudo50

@girazoki can you help with the XCM instructions please ?

crystalin avatar Jul 12 '22 11:07 crystalin

The error means that you have not set the units per second for Multilocation {parents:1, interior: here}. You can do this by using the extrinsic assetManager.set_units_per_second. This indicates how much you want to charge in your chain for this asset for xcm execution. Usually for testing purposes its fine if you set 0

girazoki avatar Aug 30 '22 07:08 girazoki

Any luck @dudo50 ? Can I close the issue?

girazoki avatar Sep 06 '22 12:09 girazoki