Skip to content

Commit 80d5be8

Browse files
committed
Add .NET support to code segment and code overview
Introduces .NET as a supported environment in the code segment component and adds .NET code snippets for contract interaction in the code overview component. This update ensures .NET developers have relevant examples for reading, writing, and listening to contract events.
1 parent b4a1b8a commit 80d5be8

File tree

2 files changed

+66
-11
lines changed

2 files changed

+66
-11
lines changed

apps/dashboard/src/@/components/blocks/code/code-segment.client.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export type CodeEnvironment =
1212
| "typescript"
1313
| "react"
1414
| "react-native"
15+
| "dotnet"
1516
| "unity"
1617
| "curl";
1718

@@ -43,6 +44,10 @@ const Environments: SupportedEnvironment[] = [
4344
environment: "react-native",
4445
title: "React Native",
4546
},
47+
{
48+
environment: "dotnet",
49+
title: ".NET",
50+
},
4651
{
4752
environment: "unity",
4853
title: "Unity",
@@ -133,7 +138,8 @@ export const CodeSegment: React.FC<CodeSegmentProps> = ({
133138
: activeEnvironment === "react" ||
134139
activeEnvironment === "react-native"
135140
? "tsx"
136-
: activeEnvironment === "unity"
141+
: activeEnvironment === "unity" ||
142+
activeEnvironment === "dotnet"
137143
? "cpp"
138144
: activeEnvironment === "api"
139145
? "javascript"

apps/dashboard/src/@/components/contracts/code-overview.tsx

Lines changed: 59 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,17 @@ export default function Component() {
6969
7070
// Get your contract
7171
var contract = await ThirdwebManager.Instance.GetContract(
72-
address: "{{contract_address}}",
73-
chainId: {{chainId}},
72+
address: "{{contract_address}}",
73+
chainId: {{chainId}},
7474
);
7575
76+
// Listen to contract events
77+
var events = await contract.Events("{{function}}");`,
78+
dotnet: `using Thirdweb;
79+
80+
// Get your contract
81+
var contract = await ThirdwebContract.Create(client, "{{contract_address}}", {{chainId}});
82+
7683
// Listen to contract events
7784
var events = await contract.Events("{{function}}");`,
7885
},
@@ -82,6 +89,9 @@ var events = await contract.Events("{{function}}");`,
8289
"react-native": "npm i thirdweb",
8390
unity: `// Download the .unitypackage from the latest release:
8491
// https://github.com/thirdweb-dev/unity-sdk/releases
92+
// and drag it into your project`,
93+
dotnet: `// Download the .unitypackage from the latest release:
94+
// https://github.com/thirdweb-dev/unity-sdk/releases
8595
// and drag it into your project`,
8696
},
8797
read: {
@@ -114,8 +124,23 @@ export default function Component() {
114124
115125
// Get your contract
116126
var contract = await ThirdwebManager.Instance.GetContract(
117-
address: "{{contract_address}}",
118-
chainId: {{chainId}}
127+
address: "{{contract_address}}",
128+
chainId: {{chainId}}
129+
);
130+
131+
// Read from the contract
132+
var result = await contract.Read<T>(
133+
contract,
134+
"{{function}}",
135+
{{args}}
136+
);`,
137+
dotnet: `using Thirdweb;
138+
139+
// Get your contract
140+
var contract = await ThirdwebContract.Create(
141+
client,
142+
"{{contract_address}}",
143+
{{chainId}}
119144
);
120145
121146
// Read from the contract
@@ -191,8 +216,16 @@ function App() {
191216
192217
// Get your contract
193218
var contract = await ThirdwebManager.Instance.GetContract(
194-
address: "{{contract_address}}",
195-
chainId: {{chainId}}
219+
address: "{{contract_address}}",
220+
chainId: {{chainId}}
221+
);`,
222+
dotnet: `using Thirdweb;
223+
224+
// Get your contract
225+
var contract = await ThirdwebContract.Create(
226+
client,
227+
"{{contract_address}}",
228+
{{chainId}
196229
);`,
197230
},
198231
write: {
@@ -241,8 +274,25 @@ export default function Component() {
241274
242275
// Get your contract
243276
var contract = await ThirdwebManager.Instance.GetContract(
244-
address: "{{contract_address}}",
245-
chainId: {{chainId}}
277+
address: "{{contract_address}}",
278+
chainId: {{chainId}}
279+
);
280+
281+
// Write to the contract
282+
var transactionReceipt = await contract.Write(
283+
wallet,
284+
contract,
285+
"{{function}}",
286+
weiValue,
287+
{{args}}
288+
);`,
289+
dotnet: `using Thirdweb;
290+
291+
// Get your contract
292+
var contract = await ThirdwebContract.Create(
293+
client,
294+
"{{contract_address}}",
295+
{{chainId}}
246296
);
247297
248298
// Write to the contract
@@ -310,8 +360,7 @@ const data = await response.json();`,
310360
const data = await response.json();`,
311361
},
312362
curl: {
313-
read: `# OR use secret key (backend only, not frontend): --header 'x-secret-key: <YOUR_SECRET_KEY>'
314-
curl https://api.thirdweb.com/v1/contracts/read \\
363+
read: `curl https://api.thirdweb.com/v1/contracts/read \\
315364
--request POST \\
316365
--header 'Content-Type: application/json' \\
317366
--header 'x-client-id: <YOUR_CLIENT_ID>' \\

0 commit comments

Comments
 (0)