#Troubleshooting Authentication with Stellar Accounts on Soroban

31 messages · Page 1 of 1 (latest)

sharp merlin
#

In [this document], the example successfully calls the increment function through [Transaction Invoker] authentication, but I want to try to authenticate using [Stellar Account]. I have made many attempts, but none of them have been successful, and I don't know where I went wrong. I would like to ask if anyone has successfully authenticated using Stellar Account, I haven't found any successful transactions on the chain 😔.

Here is the transaction I constructed:
https://horizon-futurenet.stellar.org/transactions/2c407c54556853e56e6107a100f32fd050544bb6ac839bcd3b37810c8e5c1915

The contract id is 8542841a633aafc771f07bc472b7a799fa2e82cced417356505f569daaaedc47, and the contract code is available at https://github.com/stellar/soroban-examples/tree/v0.6.0/auth.

The following are the keypairs used in the transaction:

kp0:
SAAPYAPTTRZMCUZFPG3G66V4ZMHTK4TWA6NS7U4F7Z3IMUD52EK4DDEV
GDAT5HWTGIU4TSSZ4752OUC4SABDLTLZFRPZUJ3D6LKBNEPA7V2CIG54

kp1:
SAEZSI6DY7AXJFIYA4PM6SIBNEYYXIEM2MSOTHFGKHDW32MBQ7KVO6EN
GBMLPRFCZDZJPKUPHUSHCKA737GOZL7ERZLGGMJ6YGHBFJZ6ZKMKCZTM

[this document] - https://soroban.stellar.org/docs/how-to-guides/auth
[Transaction Invoker] - https://soroban.stellar.org/docs/learn/authorization#transaction-invoker
[Stellar Account] - https://soroban.stellar.org/docs/learn/authorization#stellar-account

fallen burrow
#

cc @twin glade

#

(it's holiday in the states so people might be slower to respond)

twin glade
#

(or, of course, you can wait for more client side support)

sharp merlin
#

nonce has to correspond to the contractID of the rootInvocation. It is stored in the ledger entry with CONTRACT_DATA key with contractID from rootInvocation and SCVal key with the following value: ScVal::Object(Some(ScObject::NonceKey(address))).

@twin glade If the data described above cannot be found in the ledger entry, should the nonce be set to 0?

twin glade
#

yes

sharp merlin
twin glade
#

tx looks correct overall

#

obviously, I've no idea if symbols/signatures are correct, but the structure appears right

#

does it succeed?

sharp merlin
#

I've checked the symbols and signatures many times and I think they should be correct, but this transaction fails.

twin glade
#

ah, I see. what is the contract you're trying to invoke?

sharp merlin
twin glade
#

ok, just the example one, good

#

I think I've found one issue: the signature args needs one more external array. this is a bit unfortunate and probably should be changed, but that's what we have this release

#

though let me check...

#

here is a valid ContractAuth entry in Rust:

ContractAuth {
 address_with_nonce: Some(
 AddressWithNonce {
  address: Account(
  AccountId(
   PublicKeyTypeEd25519(
   Uint256(277b79c38cd2c1795c546b1fea23e15e03c7971d4526307f08e6b9db36ae62a2),
   ),
  ),
  ),
  nonce: 0,
 },
 ),
 root_invocation: AuthorizedInvocation {
 contract_id: Hash(933fac395a8e18efb564c85b0d6e74fb6c518327a3734ec503938e4421a7a77e),
 function_name: StringM(tree_fn),
 args: ScVec(
  VecM(
  [],
  ),
 ),
 sub_invocations: VecM(
  [
  AuthorizedInvocation {
   contract_id: Hash(668f2624ef3a4ed80d11601689a121862a134e6f90e0c5ec600633435e94c526),
   function_name: StringM(tree_fn),
   args: ScVec(
   VecM(
    [],
   ),
   ),
   sub_invocations: VecM(
   [],
   ),
  },
  ],
 ),
 },
 signature_args: ScVec(
 VecM(
  [
  Object(
   Some(
   Vec(
    ScVec(
    VecM(
     [
     Object(
      Some(
      Map(
       ScMap(
       VecM(
        [
        ScMapEntry {
         key: Symbol(
         StringM(public_key),
         ),
         val: Object(
         Some(
          Bytes(
          BytesM(277b79c38cd2c1795c546b1fea23e15e03c7971d4526307f08e6b9db36ae62a2),
          ),
         ),
         ),
        },
        ScMapEntry {
         key: Symbol(
         StringM(signature),
         ),
         val: Object(
         Some(
          Bytes(
          BytesM(f448dff40288fc32afa950d816128d0f5a74b3999af1b033febcb6bef9b6b57096bd51fc8f4fb3e8676bdca42c60102d365227e61299aa35e0807ecc0626a009),
          ),
         ),
         ),
        },
        ],
       ),
       ),
      ),
      ),
     ),
     ],
    ),
    ),
   ),
   ),
  ),
  ],
 ),
 ),
}
#

and we indeed need one more vec for the signature_args, sorry about the confusion

sharp merlin
#

@twin glade, thank you for your response 👍. I will patiently wait for the new release.

twin glade
#

oh, current release totally works as well

#

just wrap your signature args into one more sc vector, like I do here

#

it's just that this vector is redundant

#

so we should remove it. but for this release just use a wrapper vector and everything should hopefully work

sharp merlin
#

I understand, thank you. If I succeed in submitting, I will let you know.

twin glade
#

good luck! it would be cool if you make it work

twin glade
#

congrats!

sharp merlin