-
Notifications
You must be signed in to change notification settings - Fork 339
Add Examples #1265
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Add Examples #1265
Conversation
Ryang-21
commented
Nov 5, 2025
- Added examples for Rpc Server methods
- Added examples for AssembledTransaction usage
|
Size Change: -91.2 kB (-0.22%) Total Size: 42.2 MB
|
| args: [ | ||
| nativeToScVal(invoker.publicKey(), { type: 'address' }), // from | ||
| nativeToScVal(alice.publicKey(), { type: 'address' }), // to | ||
| nativeToScVal('100', { type: 'i128' }), // amount | ||
| ], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here's a nicer way I'd like to encourage people to do things
| args: [ | |
| nativeToScVal(invoker.publicKey(), { type: 'address' }), // from | |
| nativeToScVal(alice.publicKey(), { type: 'address' }), // to | |
| nativeToScVal('100', { type: 'i128' }), // amount | |
| ], | |
| args: nativeToScVal([ | |
| invoker.publicKey(), | |
| alice.publicKey(), | |
| '100' | |
| ], { | |
| type: [ 'address', 'address', 'i128' ] | |
| }).vec(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wasn't aware you could use it like that. The one problem with .vec() is that its return types use null instead of undefined which args does not take
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not spec.funcArgsToScVals as in the old docs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure what you mean by
its return types use null instead of undefined which args does not take
.vec() returns ScVal[]? which is compatible with build's any[] if you ! it
Why not spec.funcArgsToScVals as in the old docs?
There's no spec in this case from what I can tell
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I chose to not use Spec functionality as its not essential for AssembledTransaction to work. That might be a wrong choice though. My editor has the return type of .vec() as ScVal[] | null and the AssembledTransaction interface expects undefined
|
|
||
| Use `buildWithOp()` when you need to create transactions with operations other than `invokeHostFunction`, such as deploying contracts or extending TTL. | ||
|
|
||
| The following `Operations` are allowed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's worth noting that some of these aren't "real" operations in the list-of-operations sense and rather just convenience methods
| const allSigners = tx.needsNonInvokerSigningBy({ | ||
| includeAlreadySigned: true | ||
| }); | ||
| ``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we include the actual signing here as well?
IIRC you can't just sign the transaction with all parties as normal (e.g. Transaction.sign(secret)), as Soroban expects only the authorization entry itself to be signed
|
|
||
| --- | ||
|
|
||
| ## Multi-Auth Workflows |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this section different enough from the one starting on line 175 to be worth including? Seems possibly like duplicate content.