-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
30 changed files
with
2,244 additions
and
419 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Decoding script transactions | ||
|
||
The SDK offers some tools that can help you make fuel script transactions more | ||
human readable. You can determine whether the script transaction is: | ||
|
||
* calling a contract method(s), | ||
* is a loader script and you can see the blob id | ||
* is neither of the above | ||
|
||
In the case of contract call(s), if you have the ABI file, you can also decode | ||
the arguments to the function by making use of the `AbiFormatter`: | ||
|
||
```rust,ignore | ||
{{#include ../../../examples/contracts/src/lib.rs:decoding_script_transactions}} | ||
``` | ||
|
||
prints: | ||
|
||
```text | ||
The script called: initialize_counter(42) | ||
``` | ||
|
||
The `AbiFormatter` can also decode configurables, refer to the rust docs for | ||
more information. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,19 @@ | ||
script; | ||
|
||
configurable { | ||
MY_STRUCT: MyStruct = MyStruct { | ||
number: 10, | ||
boolean: true, | ||
}, | ||
A_NUMBER: u64 = 11, | ||
} | ||
|
||
struct MyStruct { | ||
number: u64, | ||
boolean: bool, | ||
} | ||
|
||
fn main(my_struct: MyStruct) -> u64 { | ||
if my_struct.boolean { | ||
my_struct.number | ||
} else { | ||
0 | ||
} | ||
fn main(arg: MyStruct) -> u64 { | ||
let _calc = MY_STRUCT.number + A_NUMBER; | ||
if arg.boolean { arg.number } else { 0 } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.