Skip to content

Commit

Permalink
Merge pull request #9 from spacemeshos/update-readme
Browse files Browse the repository at this point in the history
Update README
  • Loading branch information
brusherru authored Jul 6, 2024
2 parents 7ab8a2a + 3913394 commit 9d7fb6f
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,13 @@ See usage examples below:

```js
// Import
import { Stdtemplates, StdPublicKeys, StdMethods } from '@spacemesh/sm-codec';
import { SingleSigTemplate, StdMethods } from '@spacemesh/sm-codec';
import ed25519 from '@spacemesh/ed25519-wasm';

// SingleSig example
(async () => {
// Get SingleSig template
const singleSig = StdTemplates[StdPublicKeys.SingleSig];
(() => {
// Get method
const spawnTpl = singleSig.methods[StdMethods.Spawn];
const spawnTpl = SingleSigTemplate.methods[StdMethods.Spawn];

// Prepare SpawnPayload
const spawnPayload = {
Expand All @@ -23,7 +21,7 @@ import ed25519 from '@spacemesh/ed25519-wasm';
},
};
// Calculate Principal address (of your new account)
const principal = spawnTpl.principal(spawnPayload);
const principal = spawnTpl.principal(spawnPayload.Arguments);
// Encode SpawnTransaction
const rawTx = spawnTpl.encode(principal, spawnPayload);
// Get transaction hash, it is used in signing
Expand All @@ -35,8 +33,7 @@ import ed25519 from '@spacemesh/ed25519-wasm';

// Note: Principal method exists on any method
// So this example will work as well:
singleSig.methods[StdMethods.Spend].principal(spawnPayload);

SingleSigTemplate.methods[StdMethods.Spend].principal(spawnPayload.Arguments);
})();
```

Expand Down

0 comments on commit 9d7fb6f

Please sign in to comment.