The best way to get started with the NEAR Javascript SDK is to create a repository using the following command:
npx create-near-app@latest
You can choose Typescript and any other front end of your choice and this command will set up the end to end repository for you. The repository consists of the following main folders to look out for:
Let us quickly explore what each of the folders are doing in the following video:
https://www.loom.com/share/ed85e07fff744ee3b1744b28640ef53f
Here are some of the issues that we had faced and a few quick tips and tricks that can help:
Some of the js files present in the examples repo have a ‘lodash-es’ dependency that is being used to detect if a variable is undefined. This dependency can often cause an issue with contract compilation - so the best way to deal with it is find a workaround to the undefined check.
For example: If you do not want a particular number to be defined as an integer, you can check if it is equal to zero(or any other logic that works best in your case).
Some contracts can have a huge size(up to or more than half an MB), therefore - you may end up facing the issue of TransactionSizeExceeded during cross-contract calls. One of the workarounds that we found was to write the child contract in Rust and use the compiled .wasm to deploy it from our JS parent contract.
Some of the contract files in the example folder have .js extension (Native Javascript) and some are in .ts extension(TypeScript), so one needs to be mindful of changing the parameters in the build.sh file while building the contract.