Skip to content

Instantly share code, notes, and snippets.

@Tomen
Created October 19, 2024 17:10
Show Gist options
  • Select an option

  • Save Tomen/43da768b2820f144ffc25ee3b11a9605 to your computer and use it in GitHub Desktop.

Select an option

Save Tomen/43da768b2820f144ffc25ee3b11a9605 to your computer and use it in GitHub Desktop.
{
"source": {
"hash": "0x18d798815f261b6a2fd2158a101141ce2556ec0b42894b6fe9e6fad0e7f31d70",
"language": "ink! 5.0.0",
"compiler": "rustc 1.81.0",
"build_info": {
"rust_toolchain": "stable-x86_64-unknown-linux-gnu",
"cargo_contract_version": "5.0.0-alpha",
"build_mode": "Debug",
"wasm_opt_settings": {
"optimization_passes": "Z",
"keep_debug_symbols": false
}
}
},
"contract": {
"name": "the_button",
"version": "1.0.0",
"authors": [
"alice_und_bob <[email protected]>"
]
},
"image": null,
"version": 5,
"types": [
{
"id": 0,
"type": {
"path": [
"ink_primitives",
"types",
"AccountId"
],
"def": {
"composite": {
"fields": [
{
"type": 1,
"typeName": "[u8; 32]"
}
]
}
}
}
},
{
"id": 1,
"type": {
"def": {
"array": {
"len": 32,
"type": 2
}
}
}
},
{
"id": 2,
"type": {
"def": {
"primitive": "u8"
}
}
},
{
"id": 3,
"type": {
"def": {
"primitive": "u64"
}
}
},
{
"id": 4,
"type": {
"def": {
"primitive": "u128"
}
}
},
{
"id": 5,
"type": {
"path": [
"the_button",
"the_button",
"TheButton"
],
"def": {
"composite": {
"fields": [
{
"name": "last_press_caller",
"type": 0,
"typeName": "<AccountId as::ink::storage::traits::AutoStorableHint<::ink::\nstorage::traits::ManualKey<2326287052u32, ()>,>>::Type"
},
{
"name": "last_press_timestamp",
"type": 3,
"typeName": "<u64 as::ink::storage::traits::AutoStorableHint<::ink::storage\n::traits::ManualKey<771457355u32, ()>,>>::Type"
},
{
"name": "countdown_duration",
"type": 3,
"typeName": "<u64 as::ink::storage::traits::AutoStorableHint<::ink::storage\n::traits::ManualKey<4148362321u32, ()>,>>::Type"
},
{
"name": "min_raise_balance",
"type": 4,
"typeName": "<Balance as::ink::storage::traits::AutoStorableHint<::ink::\nstorage::traits::ManualKey<350979840u32, ()>,>>::Type"
}
]
}
}
}
},
{
"id": 6,
"type": {
"path": [
"Result"
],
"params": [
{
"name": "T",
"type": 7
},
{
"name": "E",
"type": 8
}
],
"def": {
"variant": {
"variants": [
{
"name": "Ok",
"fields": [
{
"type": 7
}
],
"index": 0
},
{
"name": "Err",
"fields": [
{
"type": 8
}
],
"index": 1
}
]
}
}
}
},
{
"id": 7,
"type": {
"def": {
"tuple": []
}
}
},
{
"id": 8,
"type": {
"path": [
"ink_primitives",
"LangError"
],
"def": {
"variant": {
"variants": [
{
"name": "CouldNotReadInput",
"index": 1
}
]
}
}
}
},
{
"id": 9,
"type": {
"path": [
"Result"
],
"params": [
{
"name": "T",
"type": 10
},
{
"name": "E",
"type": 8
}
],
"def": {
"variant": {
"variants": [
{
"name": "Ok",
"fields": [
{
"type": 10
}
],
"index": 0
},
{
"name": "Err",
"fields": [
{
"type": 8
}
],
"index": 1
}
]
}
}
}
},
{
"id": 10,
"type": {
"path": [
"Result"
],
"params": [
{
"name": "T",
"type": 7
},
{
"name": "E",
"type": 11
}
],
"def": {
"variant": {
"variants": [
{
"name": "Ok",
"fields": [
{
"type": 7
}
],
"index": 0
},
{
"name": "Err",
"fields": [
{
"type": 11
}
],
"index": 1
}
]
}
}
}
},
{
"id": 11,
"type": {
"path": [
"the_button",
"the_button",
"Error"
],
"def": {
"variant": {
"variants": [
{
"name": "CountdownNotPassed",
"index": 0
},
{
"name": "InsertCoinToContinue",
"index": 1
}
]
}
}
}
},
{
"id": 12,
"type": {
"path": [
"Result"
],
"params": [
{
"name": "T",
"type": 3
},
{
"name": "E",
"type": 8
}
],
"def": {
"variant": {
"variants": [
{
"name": "Ok",
"fields": [
{
"type": 3
}
],
"index": 0
},
{
"name": "Err",
"fields": [
{
"type": 8
}
],
"index": 1
}
]
}
}
}
},
{
"id": 13,
"type": {
"path": [
"Result"
],
"params": [
{
"name": "T",
"type": 0
},
{
"name": "E",
"type": 8
}
],
"def": {
"variant": {
"variants": [
{
"name": "Ok",
"fields": [
{
"type": 0
}
],
"index": 0
},
{
"name": "Err",
"fields": [
{
"type": 8
}
],
"index": 1
}
]
}
}
}
},
{
"id": 14,
"type": {
"path": [
"Result"
],
"params": [
{
"name": "T",
"type": 4
},
{
"name": "E",
"type": 8
}
],
"def": {
"variant": {
"variants": [
{
"name": "Ok",
"fields": [
{
"type": 4
}
],
"index": 0
},
{
"name": "Err",
"fields": [
{
"type": 8
}
],
"index": 1
}
]
}
}
}
},
{
"id": 15,
"type": {
"path": [
"ink_primitives",
"types",
"Hash"
],
"def": {
"composite": {
"fields": [
{
"type": 1,
"typeName": "[u8; 32]"
}
]
}
}
}
},
{
"id": 16,
"type": {
"def": {
"primitive": "u32"
}
}
},
{
"id": 17,
"type": {
"path": [
"ink_env",
"types",
"NoChainExtension"
],
"def": {
"variant": {}
}
}
}
],
"storage": {
"root": {
"root_key": "0x00000000",
"layout": {
"struct": {
"name": "TheButton",
"fields": [
{
"name": "last_press_caller",
"layout": {
"leaf": {
"key": "0x00000000",
"ty": 0
}
}
},
{
"name": "last_press_timestamp",
"layout": {
"leaf": {
"key": "0x00000000",
"ty": 3
}
}
},
{
"name": "countdown_duration",
"layout": {
"leaf": {
"key": "0x00000000",
"ty": 3
}
}
},
{
"name": "min_raise_balance",
"layout": {
"leaf": {
"key": "0x00000000",
"ty": 4
}
}
}
]
}
},
"ty": 5
}
},
"spec": {
"constructors": [
{
"label": "new",
"selector": "0x9bae9d5e",
"payable": false,
"args": [
{
"label": "countdown_duration",
"type": {
"type": 3,
"displayName": [
"u64"
]
}
},
{
"label": "min_raise_balance",
"type": {
"type": 4,
"displayName": [
"Balance"
]
}
}
],
"returnType": {
"type": 6,
"displayName": [
"ink_primitives",
"ConstructorResult"
]
},
"docs": [
"The constructor initializes the contract countdown duration in milliseconds.",
"The contract caller and timestamp are set to the caller and the block timestamp."
],
"default": false
},
{
"label": "default",
"selector": "0xed4b9d1b",
"payable": false,
"args": [],
"returnType": {
"type": 6,
"displayName": [
"ink_primitives",
"ConstructorResult"
]
},
"docs": [
"The default constructor initializes the contract with a countdown duration of 24 hours",
"and a minimum raised balance of 1e10 units. (1 PAS, 1 DOT, 0.01 KSM)"
],
"default": false
}
],
"messages": [
{
"label": "press",
"selector": "0x55d7a21d",
"mutates": true,
"payable": true,
"args": [],
"returnType": {
"type": 9,
"displayName": [
"ink",
"MessageResult"
]
},
"docs": [
" The caller has to pay at least 1 unit of balance to press the button.",
" The last caller and timestamp are updated. This resets the countdown.",
" If the caller has not paid enough balance, the error `InsertCoinToContinue` is returned."
],
"default": false
},
{
"label": "payout",
"selector": "0xd4805650",
"mutates": true,
"payable": false,
"args": [],
"returnType": {
"type": 9,
"displayName": [
"ink",
"MessageResult"
]
},
"docs": [
" Claims the reward if 24 hours have passed since the last press.",
" The balance of the contract is transferred to the last user who pressed the button.",
" If the countdown has not passed yet, the error `CountdownNotPassed` is returned.",
" The contract is terminated after the reward is paid out. Any remaining balance is sent to the caller."
],
"default": false
},
{
"label": "get_countdown",
"selector": "0x4a2301df",
"mutates": false,
"payable": false,
"args": [],
"returnType": {
"type": 12,
"displayName": [
"ink",
"MessageResult"
]
},
"docs": [
" Return the countdown until the next payout"
],
"default": false
},
{
"label": "get_last_press_caller",
"selector": "0xbab8826f",
"mutates": false,
"payable": false,
"args": [],
"returnType": {
"type": 13,
"displayName": [
"ink",
"MessageResult"
]
},
"docs": [
" Return the account id of the last caller"
],
"default": false
},
{
"label": "get_last_press_timestamp",
"selector": "0x5401bc27",
"mutates": false,
"payable": false,
"args": [],
"returnType": {
"type": 12,
"displayName": [
"ink",
"MessageResult"
]
},
"docs": [
" Return the timestamp of the last call"
],
"default": false
},
{
"label": "get_balance",
"selector": "0xea817e65",
"mutates": false,
"payable": false,
"args": [],
"returnType": {
"type": 14,
"displayName": [
"ink",
"MessageResult"
]
},
"docs": [
" Returns the contract balance. This is a convenience function to show the contract balance",
" in contract explorers."
],
"default": false
}
],
"events": [],
"docs": [],
"lang_error": {
"type": 8,
"displayName": [
"ink",
"LangError"
]
},
"environment": {
"accountId": {
"type": 0,
"displayName": [
"AccountId"
]
},
"balance": {
"type": 4,
"displayName": [
"Balance"
]
},
"hash": {
"type": 15,
"displayName": [
"Hash"
]
},
"timestamp": {
"type": 3,
"displayName": [
"Timestamp"
]
},
"blockNumber": {
"type": 16,
"displayName": [
"BlockNumber"
]
},
"chainExtension": {
"type": 17,
"displayName": [
"ChainExtension"
]
},
"maxEventTopics": 4,
"staticBufferSize": 16384
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment