Skip to content
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

added documentation for option to place input data in data field #93

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions warp-academy-docs/docs/sdk/advanced/warp-extensions.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,22 @@

### Input in data

According to the [SmartWeave protocol](./smartweave-protocol.md), input of the interaction can be stored in its tags, more specifically - in the Input tag. However, we are then limited by the transaction tag’s size limit - 4kb for the transaction (including all the default tags that Warp applies). Due to this problem, a new way of storing input - in the data field of the transaction - was introduceed in Warp. It does not require any changes from the user perspective. Warp SDK checks the input size and decide wether it should be placed in the tag or - if it exceeds the limit - in the data field of the transaction. Interaction is then sent to the Warp Sequencer and indexed as usual - so it is available in all of the Warp tools as it’s been before. Particularly - contract state of the contract is evaluated regardless of the input type.
According to the [SmartWeave protocol](./smartweave-protocol.md), input of the interaction can be stored in its tags, more specifically - in the Input tag. However, we are then limited by the transaction tag’s size limit - 4kb for the transaction (including all the default tags that Warp applies). Due to this problem, a new way of storing input - in the data field of the transaction - was introduced in Warp. It does not require any changes from the user perspective. Warp SDK checks the input size and decide wether it should be placed in the tag or - if it exceeds the limit - in the data field of the transaction. Interaction is then sent to the Warp Sequencer and indexed as usual - so it is available in all of the Warp tools as it’s been before. Particularly - contract state of the contract is evaluated regardless of the input type.

A new tag - `Input-Format` has been added to the interaction. It is set to either tag or data depending on the way of storing input.
A new tag - `Input-Format` has been added to the interaction. It is set to either tag or data depending on the size of the interaction input, defaulting to the tag field if transaction tag size is less than the 4kb limit. However, to override this default behavior and explicitly have interaction input placed in the data field, `writeInteraction` should be called with the `inputFormatAsData` option set to `true`.

<details>
<summary>Example</summary>

```typescript
const result = await contract.writeInteraction(
{
function: "NAME_OF_YOUR_FUNCTION",
data: { ... },
},
{ inputFormatAsData: true }
);
```
</details>

As of now, limit for the interaction data item is set to 20kb. New feature works only for the bundled data items (so no way of sending big inputs in Arweave L1 interactions).
2 changes: 1 addition & 1 deletion warp-academy-docs/docs/sdk/basic/contract-methods.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ Writes a new "interaction" transaction - i.e. such transaction that stores input
The interaction transactions are loaded during the contract state evaluation.

- `input` the interaction input
- `options` - an object with some custom options (see [WriteInteractionOptions](https://github.com/warp-contracts/warp/blob/main/src/contract/Contract.ts#L49))
- `options` - an object with some custom options (see [WriteInteractionOptions](https://github.com/warp-contracts/warp/blob/main/src/contract/Contract.ts#L57))

In case of the `forMainnet` and `forTestnet` obtained `Warp` instances, interaction transactions are bundled and posted on Arweave using Warp Sequencer.
If you want to post transactions directly to Arweave - disable bundling by setting `options.disableBundling` to `true`.
Expand Down