You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Call `TxScript` is a feature that allows interaction with smart contracts on Alephium without consuming gas and modifying the on-chain state. Instead, it executes scripts and returns updated contract states.
The `main` function of `TxScript` serves as the entry point for contract code execution. It supports both explicit and implicit definitions of the `main` function:
341
+
342
+
1. Implicit definition of the `main` function, in the example above, the compiler automatically generates a `main` function for the `TxScript`.
343
+
2. Explicit definition of the `main` function:
344
+
345
+
```rust
346
+
TxScriptMain(foo:Foo) {
347
+
@using(preapprovedAssets =false)
348
+
pubfnmain() -> () {
349
+
bar()
350
+
foo.foo(0)
351
+
}
352
+
}
353
+
```
354
+
355
+
The explicitly defined `main` function cannot have parameters. If you need to specify parameters, you can pass them as parameters of the `TxScript`.
356
+
340
357
## Gasless Transaction
341
358
342
359
In Ralph, you can use the built-in `payGasFee` to pay transaction gas fees on behalf of the user, for example:
0 commit comments