From ca33af97e48b55c1a3d57e06e8490ff9e8596378 Mon Sep 17 00:00:00 2001 From: luc10921 Date: Tue, 7 Nov 2023 14:35:46 -0300 Subject: [PATCH] CU-8678g5b7w - Create an article on neo website explaining how to use cpm for TS offchain sdk generation with neon-dappkit and wcsdk --- .../assets/CPM-logo.png | Bin 0 -> 13997 bytes .../index.md | 109 ++++++++++++++++++ 2 files changed, 109 insertions(+) create mode 100644 tutorials/2023-11-06-offchain-sdk-ts-generation-with-cpm/assets/CPM-logo.png create mode 100644 tutorials/2023-11-06-offchain-sdk-ts-generation-with-cpm/index.md diff --git a/tutorials/2023-11-06-offchain-sdk-ts-generation-with-cpm/assets/CPM-logo.png b/tutorials/2023-11-06-offchain-sdk-ts-generation-with-cpm/assets/CPM-logo.png new file mode 100644 index 0000000000000000000000000000000000000000..3270ccbf60e7ce5b9581decf27feee0bbf1f1385 GIT binary patch literal 13997 zcmeHudpK0<`}f}ERE`}`37tevQz^!D)zTBtAHRnmbN%!8_7B!H^p{1K_WOkY z_M7Ii`S`O=y{Qk3&A+P}V| z-vH6K*57{HUU6X0?&DVZi9%vJOXlGt&9*R}gh9p(&e=B^w;MSi3 zZI6N;(PYr$Jv3_rgKHky=yU%2`mY53r%PbfPX7Q}Md?lx{-@IZkuJGZ6yHW(@%TtJTvO42J?ZB83`H8D7TkWx3iyNh~JKKeUwrKGsnlvG z>YBZy@&%agblev5y{2BHeq^RN;tZ6$*S@}fRO&zK%YSmsHzfYhU`?s(-z~ir5qPNc z^FI6f{j8jSpv`M}S$~nLVkVdg$G){aX21*BAXQNETSz-w0hd zl7v2JHc!p}a#@3@v!7^;C?8nWV{X3P4^mmRf6UPZV-_lQ-WRIp10aZeTj z8|d0D%i#SgMsXXVdm8pyhr#trP&mJ#f03jG&xb#)jzf#@?acnc-ovh?UZ#oRSXD%nW^+y}M@98ITZd zJP+s_yCj_+867~TKd1b>N>R?tiVMP8p5GNHK8vpjbxh%^R;j!p{)wV)D%6?dBp^*clUReVXPV+6<7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w2LhV{&j761A>CS#)Fp5#7DrnecABpT<6jxywZ!{f27Rn?)R zeBfPJYULRd<+n68PTWAXu;$3x-4=t_ILGI+fvGD;# zN56|Rcg>jFd!o`BD8XwYxjDJHEKyGjH8L_hT-Mdl&?T1-l2cNe4j$%{{#}$a2wCCx ziAci$@9>)Tw{6aYLG!(||80)_|GgvF*w^8P@uL5uTRNW~?;gAS4+7G)q+r`Sv8j4Z5ysUyt^V0w+tI)YM<-4!<@e0!w|8)Pth^rocQu_wxTtZS_5HMDwYgHlw4r0u)h+NrTYSb9JhuH6o^j~ z!*p$*WK?~YyR5m!0^Zg}#uS#vtuQg8gw%?2+9Yd<4g@B3wdhXkc9n_Avv!m{oE{Tj ze#A939j_kiLiMonQrhtgx8NbP`FMSoY<7;gUgdxKzcl=JegBmJDgp0)<-%8=7A_k# S+WmcAAP4rk@5%p@NdI3`WgM;m literal 0 HcmV?d00001 diff --git a/tutorials/2023-11-06-offchain-sdk-ts-generation-with-cpm/index.md b/tutorials/2023-11-06-offchain-sdk-ts-generation-with-cpm/index.md new file mode 100644 index 0000000..3ab19f0 --- /dev/null +++ b/tutorials/2023-11-06-offchain-sdk-ts-generation-with-cpm/index.md @@ -0,0 +1,109 @@ +--- +slug: coz-create-ts-sdk-with-cpm +title: 'How to use CPM to generate an off-chain TypeScript SDK' +description: "The tutorial aims to provide a comprehensive guide for developers interested in creating TypeScript SDKs for Neo smart contracts, making it easier for them to leverage CPM and successfully work with off-chain SDKs." +author: coz.io +tags: ["TS", "CPM", "SDK"] +skill: BEGINNER +image: "./assets/CPM-logo.png" +sidebar: true +--- + +[CPM](https://github.com/CityOfZion/cpm) is a tool that can help you download smart contracts and generate on-chain and off-chain SDKs for multiple languages without the need to write them yourself and needing none or minimal changes. + +## 1. Initializing workspace +We recommend using [vite](https://vitejs.dev/guide/) to create your project from a template. You just need to run `npm create vite@latest` and select the prompts to generate your project. After creating your project, it's time to start using CPM to automate the off-chain SDK generation. + +## 2. Using CPM +It's pretty easy to use CPM to add an off-chain SDK to your TypeScript project. After installing CPM you can generate a single SDK directly from the command prompt or setup a configuration file that will be processed and allows for generating multiple SDKs at the same time. In this tutorial, we will be using the easiest one to maintain. + +We need to generate a configuration file by running `cpm init` on the terminal. This creates a `cpm.yaml` file that by default gets the [Props](https://github.com/CityOfZion/props) smart contract. While it is a useful contract, it's probably not the one you want, in this article, let's suppose we want to easily invoke functions from the [Neo Token contract](https://dora.coz.io/contract/neo3/mainnet/0xef4073a0f2b305a38ec4050e4d3d28bc40ea63f5). + +The configuration file is divided into 4 different sections that will be tweaked to generate the desired SDK: +- `defaults`: will indicate that we want to generate an off-chain TypeScript SDK inside the `src` folder and that we don't want to download the NEF and manifest; +- `contracts`: will have the Neo Token contract that we want to generate an SDK for; +- `tools`: since we don't want to download the smart contract, this section is unnecessary; +- `networks`: will have the Main Net network where the Neo Token contract is. + +After tweaking the `cpm.yaml` file it should be something like this: + +```yaml +defaults: + contract-source-network: mainnet + contract-generate-sdk: true + contract-download: false + off-chain: + languages: + - ts +    destinations: + ts: src/contracts + +contracts: + - label: NEO token + script-hash: '0xef4073a0f2b305a38ec4050e4d3d28bc40ea63f5' + +networks: + - label: mainnet + hosts: + - 'https://mainnet1.neo.coz.io:443' + - 'http://seed1.neo.org:10332' +``` + +> For more information on how to configure `cpm.yaml`, check out [CPM's documentation](https://github.com/CityOfZion/cpm/blob/master/docs/config.md) + +Then just run `cpm run` on the terminal and the SDK should be generated at the `src/contracts/neotoken` folder. Anytime the contract adds or removes method signatures, you'll have to run `cpm run` again to update your SDK. + +## 3. Initializing and running the SDK +Now that the SDK is already generated, you'll need to install the dependencies: [`@types/node`](https://www.npmjs.com/package/@types/node), and [`@cityofzion/neon-dappkit-types`](https://www.npmjs.com/package/@cityofzion/neon-dappkit-types). Then you'll have to import and initialize the SDK to be able to call it. +To initialize the SDK, you'll first need to instantiate a class that implements `Neo3-Invoker`. +To enhance security and user experience, it's advisable to use [`WalletConnect`](https://github.com/CityOfZion/wallet-connect-sdk) for scenarios requiring user authentication, such as signing transactions or accessing user account details. However, for situations where such authentication is unnecessary, [`NeonInvoker`](https://github.com/CityOfZion/neon-dappkit/blob/main/packages/neon-dappkit/src/NeonInvoker.ts) from NeonDappkit offers a more streamlined solution, as it eliminates the need for users to approve requests through their wallets. In our example, we employ both methods: NeonInvoker is utilized when the user is not logged into their wallet. +```ts +import { NeoToken } from './contracts/neotoken' + +import { Neo3Invoker } from "@cityofzion/neon-dappkit-types" +import { NeonInvoker } from "@cityofzion/neon-dappkit" +import WcSdk from '@cityofzion/wallet-connect-sdk-core' + + +let wcSdk: WcSdk +let neonInvoker: NeonInvoker + +async function initInvokers() { + wcSdk = await WcSdk.init({ + projectId: 'a9ff54e3d56a52230ed8767db4d4a810', // the ID of your project on Wallet Connect website + relayUrl: 'wss://relay.walletconnect.com', // we are using walletconnect's official relay server + metadata: { + name: 'MyApplicationName', // your application name to be displayed on the wallet + description: 'My Application description', // description to be shown on the wallet + url: 'https://myapplicationdescription.app/', // url to be linked on the wallet + icons: ['https://myapplicationdescription.app/myappicon.png'], // icon to be shown on the wallet + }, + }) + + neonInvoker = await NeonInvoker.init({ + rpcAddress: NeonInvoker.MAINNET, + }) +} + +function getInvoker(): Neo3Invoker { + if (wcSdk.isConnected()) { + return wcSdk + } else { + return neonInvoker + } +} +``` +> To connect a wallet to your application, checkout [Wallet Connect's documentation](https://github.com/CityOfZion/wallet-connect-sdk/blob/main/USAGE_GUIDE.md#connect-to-the-wallet) + +Then you can invoke the contract methods with this SDK: +```ts +async function main() { + const neoToken = new NeoToken({ + scriptHash: NeoToken.SCRIPT_HASH, + invoker: getInvoker() + }) + console.log(await neoToken.symbol()) // NEO + console.log(await neoToken.decimals()) // 0 + console.log(await neoToken.totalSupply()) // 100000000 +} +```