[Solved] Easy development of JS-SDK?

Simple Usage: with tag,I finished creating mnemonics and generated public and private keys.

Now how do I call a method function to initiate a token transfer? And how should I sign?
@nduchak.chain
@davidyuk

1 Like

I plan to use JavaScript to complete it in the browser, and then send the signed Tx to the node broadcast.

1 Like

Are there related functions under the Ae variable? How should I use it? Or not yet? Can you help me?
@nduchak.chain @davidyuk

1 Like

Hey @LiuShao.chain,
Please try this example:

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
</head>
<body>
  <!-- include latest SDK version -->
  <script src="https://unpkg.com/@aeternity/aepp-sdk/dist/aepp-sdk.browser-script.js"></script>
  <script type="text/javascript">
    Ae.Node({ url: 'https://sdk-testnet.aepps.com' }).then(node => {
        const account = Ae.MemoryAccount({ keypair: { secretKey: 'YOUR_PRIV', publicKey: ' YOUR_PUB' } })
        Ae.Universal({
              nodes: [{ name: 'local', instance: node }],
              accounts: [ account ]
            }).then(aeInstance => {
              aeInstance.spend(RECIPIENT_PUB, 1e18).then(spendTx => { // Send 1 AE
                console.log("SPend TX:" + spendTx)
              })
            })
    })
  </script>
</body>
</html>

Thanks @nduchak.chain , I try.
Is there a way to encrypt it locally as Tx_ and then sign it? TX was broadcast last.
I see in Ae.Crypto, and Ae.sign seems to have this method?

Yes, please check this aepp-sdk-js/low-vs-high-usage.md at develop · aeternity/aepp-sdk-js · GitHub

@LiuShao.chain please let us know if your issue is resolved.

1 Like

Are there any plans to offer courses in China?

Hey @beijing

The Dacade 101 course on AE Development is translated into Chinese - see below:

We are now working on more advanced courses that will be translated as well.

Best,
Albena

No, I’m stupid. In the example, I run it to prompt AENS related errors. Not too clear where AENS is involved.

@LiuShao.chain can you please share your code snippet, then i can fix it

Thank you @nduchak.chain ,
I was negligent. Now it works fine.
But I don’t seem to add the payload field.

Spend with payload: await client.spend(RECIPIENT, AMOUNT, { payload: 'Hello' })

Thanks @nduchak.chain , I have done it. Now there are new problems.

const KS = Ae.Keystore.dump('test','pwd',skey)

I did it like this, it seemed to succeed.
But when i

const priv =  Ae.Keystore.recover('pwd', KS)

It doesn’t seem to work.

Hey,
What did you get(some Error)?
Provide please little bit more info, for me it’s works

Is my method wrong?

Am I importing the wrong format? I imported secretKey directly.

For example, I use the secretKey for testing
367310f096ee2ac98e2f9e0f80761a85b3e3daa9274d392f601c72b80f67f8a0e14496f6ec5b3204526da3855e6ea9ba98eee1fba3fd7e76c28b2f7756790343

But when I am AE.Keystore.Recover ()

3336373331306630393665653261633938653266396530663830373631613835623365336461613932373464333932663630316337326238306636376638613065313434393666366563356233323034353236646133383535653665613962613938656565316662613366643765373663323862326637373536373930333433

It doesn’t seem to be what I need. Does it need hex or how to deal with it?

你这是要做什么项目?用什么语言做的?????

Hey @xupei please stick to English. Thank you.