Skip to content

Commit e730a6d

Browse files
committed
add info about the typings of constructor & function arguments to docs
1 parent b7a030c commit e730a6d

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

website/docs/language/contracts.md

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,17 @@ contract HTLC(pubkey sender, pubkey recipient, int expiration, bytes32 hash) {
2929
}
3030
```
3131

32+
:::info
33+
The typings for the constructor arguments are only semantic and used when initilaizing the contract with the SDK. This means when not using the SDK you could still pass a different byte length item to `bytes32 hash`.
34+
:::
35+
36+
3237
:::note
33-
Upon initialization of the contract, constructor parameters are encoded and added to the contract's bytecode in the reversed order of their declaration. This can be important when manually initializing contracts for debugging purposes.
38+
Upon initialization of the contract, constructor parameters are encoded and added to the contract's bytecode in the reversed order of their declaration. This can be important when manually constructing the contract locking script for debugging purposes.
3439
:::
3540

3641
## Functions
37-
The main construct in a CashScript contract is the function. A contract can contain one or multiple functions that can be executed to trigger transactions that spend money from the contract. At its core, the result of a function is just a yes or no answer to the question 'Can money be sent out of this contract?'. However, by using a technique called covenants, it's possible to specify additional conditions — like restricting *where* money can be sent. To read more about this technique, refer to the [CashScript Covenants Guide](/docs/guides/covenants).
42+
The main construct in a CashScript contract is the function. A contract can contain one or multiple functions that can be executed to trigger transactions that spend money from the contract. At its core, the result of a function is just a yes or no answer to the question 'Can money be sent out of this contract?'. However, by using 'covenants it's possible to specify additional conditions — like restricting *where* money can be sent. To learn more about covenants, refer to the [CashScript Covenants Guide](/docs/guides/covenants).
3843

3944
#### Example
4045
```solidity
@@ -51,8 +56,12 @@ contract TransferWithTimeout(pubkey sender, pubkey recipient, int timeout) {
5156
}
5257
```
5358

59+
:::caution
60+
The typings for the function arguments are only semantic, this means the length of bounded bytes types like `bytes20` are **not** contract enforced automatically. Instead add an explicit length check `require(item.length == 20)`.
61+
:::
62+
5463
:::note
55-
Function parameters are passed in the reversed order of their declaration. This can be important when manually creating contract transactions for debugging purposes.
64+
Function parameters are passed in the reversed order of their declaration. This can be important when debugging or when creating transactions manually.
5665
:::
5766

5867
## Statements

0 commit comments

Comments
 (0)