archethic-foundation / archethic-foundation/libjs

Need help to interact with a contract

Open
#212 4 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
19
Forks
17
PR merge metrics
No merged PRs in 30d

Description

Hello, I've seen a lot of documentation, I think it's very good but unfortunately I still can't sign a transaction. I've come here in the hope that someone will be able to help me. I'll try to describe my problem as fully as possible.
```ts
archethic
.connect()
.then(async () => {

const secretKey = Crypto.deriveAddress(userSeed, 0)
const cipher = Crypto.aesEncrypt(secretKey, seed);

const authorizedKeys = [
{
publicKey: seed,
encryptedSecretKey: Crypto.ecEncrypt(secretKey, seed),
},
];
const originPrivateKey = Utils.originPrivateKey;

const tx = archethic.transaction
.new()
.setType('transfer')
.addUCOTransfer(poolAddressesUcoAeETH, Utils.toBigInt(1))
.addOwnership(cipher, authorizedKeys)
.build(seed,0)
.originSign(originPrivateKey);

tx.on('confirmation', (nbConf, maxConf) => console.log(nbConf, maxConf))
.on('error', (_, err) => console.log(err))
.on('timeout', (_) => console.log('timeout'))
.send();
})
.catch((a) => {
console.error(a);
});
```

my userseed looks like this : "pirate bateau chimie .... "
my seed looks like this : "0000FD163D0CAD7CF62A6239A037EDABC27AD8467AD2898F899A88C7F9B52D771792"

I know that this code is not at all correct, and that I don't understand all these different keys, if anyone can help me.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the `archethic.transaction.new()` entry point and the transaction-signing and ownership documentation referenced by the issue. Review the key derivation, encryption, signing, and transfer steps, then verify the example can submit a transaction and receive confirmation without exposing seed material.

Written by the indexing model from the issue text.

Assessment

Tech stack
blockchain, typescript
Domain
blockchain
Issue type
Documentation
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
15/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.