0x2bfa3a690b88f51c03ddf63e16d9ce55818ca417e6f52adb4b0ab326572bb9e3
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
export async function tryGetRevertReason(to: string, from: string, data: string): Promise<string | undefined> { | |
const provider = ethers.getDefaultProvider(); | |
const tx = { to, from, data }; | |
try { | |
await provider.estimateGas(tx); | |
} catch { | |
const value = await provider.call(tx); | |
return hexDataLength(value) % 32 === 4 && hexDataSlice(value, 0, 4) === '0x08c379a0' | |
? defaultAbiCoder.decode(['string'], hexDataSlice(value, 4)) | |
: undefined; |
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
type request is record | |
callback : contract(int) | |
end | |
type action is | |
| GetBar of (request) | |
| SetBar of (int) | |
type store is record | |
bar: int; |
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
type action is | |
| GetFoo of (address) | |
| SetFoo of (int) | |
type store is record | |
foo: int; | |
end | |
type return is list (operation) * store |
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
type action is | |
| Increment of (int) | |
| Decrement of (int) | |
| Reset of (unit) | |
type store is int | |
type return is list (operation) * store | |
const emptyOps: list(operation) = list end |
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
type action is | |
| Increment of (int) | |
| Decrement of (int) | |
| Reset of (unit) | |
type store is unit | |
type return is list (operation) * store | |
const dest : address = ("KT1ExEhdgHTzotFdPsp4mhNC6rqK4h6EKUQu" : address) |
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
{ | |
"mnemonic": [ | |
"essence", | |
"crucial", | |
"useful", | |
"blush", | |
"phone", | |
"private", | |
"found", | |
"apple", |
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
{ | |
"mnemonic": [ | |
"pepper", | |
"elbow", | |
"pizza", | |
"best", | |
"speak", | |
"usual", | |
"mass", | |
"pepper", |
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
// Error codes used with the `failwith` method , for contract execution termination. | |
const error_not_enough_balance : string = "0"; | |
const error_transaction_of_funds_failed : string = "1"; | |
const error_amount_must_be_zero : string = "3"; |
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
const emptyOps : list(operation) = list end; | |
function approve (const addressSpender : address; const value : nat; var store : store) : return is | |
block { | |
// If sender is the spender approving is not necessary | |
if sender = addressSpender then skip; | |
else block { | |
const senderAccount: account = getAccount(sender, store.accounts); | |
var allowance: nat := getAllowance(addressSpender, senderAccount.allowances); |
NewerOlder