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
Create a new file in the `src` folder called `CounterCore.sol`, and inherit the `Core` contract.
31
36
32
-
```solidity
33
-
// SPDX-License-Identifier: UNLICENSED
34
-
pragma solidity ^0.8.20;
37
+
```solidity
38
+
// SPDX-License-Identifier: MIT
39
+
pragma solidity ^0.8.20;
35
40
36
-
import {Core} from "modular-contracts/src/Core.sol";
41
+
import {Core} from "@thirdweb-dev/src/Core.sol";
42
+
import {BeforeIncrementCallback} from "./interface/BeforeIncrementCallback.sol";
37
43
38
-
contract CounterCore is Core {
44
+
contract CounterCore is Core {
45
+
constructor(address owner) {
46
+
_initializeOwner(owner);
47
+
}
48
+
}
39
49
40
-
constructor(address owner) {
41
-
_initializeOwner(owner);
42
-
}
50
+
```
51
+
52
+
> **Note**
53
+
> The `Core` contract is the base contract that needs to be inherited for this contract to be recognized as a core contract.
54
+
55
+
</Step>
43
56
44
-
}
45
-
```
57
+
<Steptitle="Set Get Supported Callback Function">
58
+
Implement the `getSupportedCallbackFunctions` function. The Core contract is abstract because this function is not implemented. To avoid compilation errors, declare the function with an empty body for now.
46
59
47
-
> **Note**
48
-
> The `Core` contract is the base contract that needs to be inherited for this contract to be recognized as a core contract.
Introduce the `_beforeIncrement` function to use the `beforeIncrement` callback from a module.
115
+
Introduce the `_beforeIncrement` function to use the `beforeIncrement` callback from a module to achieve this, we'll introduce the interface `BeforeIncrementCallback`
78
116
79
-
> **Note**
80
-
> Callback functions are hook-like functionalities that can be used before or after the main functionality of a core contract.
81
-
> In this example, the `beforeIncrement` callback is executed before the main increment functionality.
117
+
> **Note**
118
+
> Callback functions are hook-like functionalities that can be used before or after the main functionality of a core contract.
119
+
> In this example, the `beforeIncrement` callback is executed before the main increment functionality.
82
120
83
-
```solidity
84
-
// SPDX-License-Identifier: UNLICENSED
85
-
pragma solidity ^0.8.20;
121
+
```solidity
122
+
// SPDX-License-Identifier: MIT
123
+
pragma solidity ^0.8.20;
86
124
87
-
import {Core} from "modular-contracts/src/Core.sol";
125
+
import {Core} from "@thirdweb-dev/src/Core.sol";
88
126
89
-
interface BeforeIncrementCallback {
90
-
function beforeIncrement(uint256 count) external returns (uint256);
91
-
}
127
+
// 👇👇👇👇👇👇👇👇👇
92
128
93
-
contract CounterCore is Core {
94
-
uint256 public count;
129
+
interface BeforeIncrementCallback {
130
+
function beforeIncrement(uint256 count) external returns (uint256);
Implement the `getSupportedCallbackFunctions` and `supportsInterface` functions to expose which callback functions and interfaces this core contract supports.
147
+
function increment() public {
148
+
count += 1;
149
+
}
121
150
122
-
```solidity
123
-
// SPDX-License-Identifier: UNLICENSED
124
-
pragma solidity ^0.8.20;
151
+
// 👇👇👇👇👇👇👇👇👇
125
152
126
-
import {Core} from "modular-contracts/src/Core.sol";
Implement the `getSupportedCallbackFunctions` and `supportsInterface` functions to expose which callback functions and interfaces this core contract supports.
171
+
172
+
```solidity
173
+
// SPDX-License-Identifier: MIT
174
+
pragma solidity ^0.8.20;
175
+
176
+
import {Core} from "@thirdweb-dev/src/Core.sol";
177
+
178
+
interface BeforeIncrementCallback {
179
+
function beforeIncrement(uint256 count) external returns (uint256);
0 commit comments