spendTx to AENS names

recently I had a discussion with @philipp.chain because I thought it isn’t possible to send directly to AENS names (which of course need an account_pointer set) and then he showed me the docs of the protocol:

there it is stated that for the recipient an AENS name can be used (e.g. kryptokrauts.chain).

now I want to verify this with our java sdk and I am wondering how the RLP encoding should be handled when an AENS name is provided.

is there currently a SDK which supports sending to AENS names directly (without looking up the account_pointer beforehand)? @noandrea

Just to clarify, the transaction can handle: A name identifier, whose related name entry has an identifier as value of pointer with key account_pubkey. If multiple pointer entries are present for such key, then the first of such entries is used.

I.e. you can’t put a name there, but a name identifier (a name hash). The encoding is just like when you encode an account identifier, the tag for account is 1, the tag for name is 2.

As usual I have no clue what the SDKs are doing, sorry for that.

1 Like

ok so the recipient wouldn’t be kryptokrauts.chain but instead nm_xyz, right?

I didn’t test this. But if it is so then the SDKs should all support this looking at the implementation. Will verify now in the java sdk. Thanks!

Yes the spendTx recipient could be ak_..., ok_..., ct_... or nm_... (properly encoded).

when testing this with with our java sdk and nodes running v5.0.1 of the protocol it seems to determine a wrong recipient address. will now update the local testnodes and investigate whats happening there

edit:

  • the current implementation of our java-sdk results in performing a spendTx to the hash of the name-id
  • if the name is nm_2mjiHLEK2BeELdN1CDk5vSJhda3C2U1oC3CSq2iXnhmngBhWWK the recipient will be ak_2mjiHLEK2BeELdN1CDk5vSJhda3C2U1oC3CSq2iXnhmngBhWWK

we were always using the account-tag in the RLP encoding so wie need to check beforehand what identifier is being used :+1: … works now :slight_smile: … will be fixed in v2.2.0 of the java sdk

@noandrea can you verify whether this is being handled correctly in other SDKs?

1 Like

hello @marc0olo , the spend by name has been misunderstood in the past,
the py and js SDK for the spend they will use the name hash as recipient.

The name hash does not depend from the account address that has registered it, but only by the name being registered.

What is going to happen is that if there is a pointer with key: account_pubkey the value of that pointer will be used as actual recipient of the tx, if that pointer is not found then the tx will just never be included.

The right thing to do for spend by name as an SDK is probably to fetch the name, verify if there is a pointer with the right key, and only then broadcast the transaction.

2 Likes

Is this only possible via the aeternal middleware or can that be done via node http api?

it is possible also using the http API of the node