leonardocustodio / polkadart

Polkadart provides developers the ability to query a node and interact with the Polkadot or Substrate chains using Dart.
Apache License 2.0
25 stars 14 forks source link

Transaction to an address in string #420

Closed web3-sante closed 8 months ago

web3-sante commented 8 months ago

Hello team, dumb question here:

How to execute a simple transfer to an address in this format

    final BOB = '5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty';

without also having to grab infos like block hash, genesis... but just something in this style.

What would be the best way or place to ask questions without having to open issues?

leonardocustodio commented 8 months ago

Hello @web3-sante, right now, that's not possible. We started this project last year and there is a lot to be done yet. We are first working on supporting everything Polkadot can do, after that when people can do everything (in a harder or easier way) then we will start to work in the helpers and things to reduce the boilerplates. Feel free to send PR's if you make something and would like to contribute. And for now, issues here are the best (and only place), so no worries.

web3-sante commented 8 months ago

Hello @web3-sante, right now, that's not possible. We started this project last year and there is a lot to be done yet. We are first working on supporting everything Polkadot can do, after that when people can do everything (in a harder or easier way) then we will start to work in the helpers and things to reduce the boilerplates. Feel free to send PR's if you make something and would like to contribute. And for now, issues here are the best (and only place), so no worries.

Thanks @leonardocustodio for the reply.

May be I asked the question the wrong way.

Assuming we are on polkadot how one would do to make a transfer instead of transferAll , how to encode/decode the BOB address: 5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty; so we can use it in api.tx.balances.transfer

Something like this:

final BOB = '5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty';
final bobAddr =  ..... // Encoded Decoded
final transfer = api.tx.balances.transfer(dest: bobAddr, value: BigInt.from(11111) );

Feel free to send PR's if you make something and would like to contribute. And for now, issues here are the best (and only place), so no worries.

it's noted asap something is done on my side.

leonardocustodio commented 8 months ago

Ah I see, I thought you wanted a signAndSend method that would get the wallet from keyring, sign and send, without having to construct the SigningPayload and Extrinsic data.

For the above, it is pretty simple:

import 'package:polkadart_example/generated/polkadot/polkadot.dart';
import 'package:ss58/ss58.dart';
import 'package:polkadart_example/generated/polkadot/types/sp_runtime/multiaddress/multi_address.dart';

final bob = Address.decode('5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty');
final runtimeCall = api.tx.balances.transfer(dest: MultiAddress.values.id(bob.pubkey), value: BigInt.from(1000000000000));
web3-sante commented 8 months ago

Awesome @leonardocustodio Thanks 🙏 !