# Encode Club NEAR Bootcamp - DAY 8 [26/01/2022] --- ## [Day 8 Recording](https://youtu.be/TTmJCjDNniQ) --- # Questions: --- [Journey of an NFT]( https://hackmd.io/hA4oLqOzSa-_F3S0gcwO5g?view ) ## Issue on executing the contract shows "Failure contract method not found"? *Explanation of contract:* * line 3 --> Got an account that is using the contract.Starting it by deleting the account. * line 5 --> Recreating the account as sub-account with master account right next to it. * line 7 --> Building the contract by using the compiler script that gives wasm. * line 9 --> Deploy the wsam (web assembly) file to the same account specifing it goes to main.wasm. ![](https://i.imgur.com/8tnVI0Q.png) -- The first two steps deleting and creating an account are handled online on the network. -- Its not clear with compiler.js which creates wasm file and put its to the our folder. Checking compiler.js to know the process is happening and its look like doing something with out main wasm. ## How to use gas when deploying a contract or call another contract error: gas exceeded? Brief about contract: * On the left side of screen is one contract with a method in order to do some calculation with two parameters. * The right side is smart contract that going to call the left. * In the `promise` method its given gas (15 teragas) and while running the contract it shows Prepared gas exceeded. The idea is to debug the code but need to know about the gas when we create a `promise` and executed. ![](https://i.imgur.com/WwIJFaS.png) -- In the main contract which has some method called `add` which is adding this number to some other contract which is set on line-5(dev-164***) and the method called longaddnumbers on the left hand side of screen on line3. -- so when the `promise` is created inside the method which is running a receipt is created to call out the other contract function by passing these arguments. -- The line24 will not work because the object declaration need some custom type or primitive for the arguments.The encoding of arguments needs to be a type that is tagged with nearby gen so that we can encode it. -- In basic gas you can attach maximum of 300 teragas. -- This is the process of add method inside of calculator api and its being used by line40 and 41 to make new instance of calculator then you can call add then return that as a result. ![](https://i.imgur.com/p8Hr1xD.png) -- On testing the file with jest a frontend tool the contract being compiled but its being tested locally so the account dev164 doesnt exists locally. so important thing is the system you working with is designed to be able to compile code and put it onto decentralized network were the account or dev or number present. -- On calling into that network like some 100 of machines running and ticking inside one of thoes tick the function is running and you will get response back. -- But when testing locally is like faking it so the complexity of cross contract calls in the unit tesing framework is like workspace/simulation test is independent to that function so you wont get the sophistication of network. -- So the contract in the left side of the screen can be done with unit test. -- The contract that is setting up `promise` cant test using the unit test that can test in some simulation environment or testnet. -- The conclusion is you cant test cross contract call with unit test its unsupported. So the correct test is to deploy the testnet and call it there and then monitor the transaction then you will see the receipts bouncing back and forth. -- [cross contract calls](https://github.com/near-examples/cross-contract-calls) this gives full explanation the process with some contract examples. --- # Workspace of new machinery for simulation testing tool **[WorkSpace](https://youtu.be/TTmJCjDNniQ?t=1966)** [Aha Labs](https://ahalabs.dev/) Installing, Create-near-app you can install with `npm i-g create-near-app` it need node greater then version 12. `Create-near-app--help ` ![](https://i.imgur.com/NspXN2q.png) Here you can set contract language and frontend. *Warning:* Create-near-app is not maintained by any one,some update are relesed on 2.0.1 version but its not guaranteed to uptodate. For contract its going to be default:assemblyscript and change the frontend. **Installing the frontend:** Creating three application using frontend ``` create-near-app--frontend vanilla can-vanilla create-near-app--frontend react can-react create-near-app--frontend vue can-vue ``` ![](https://i.imgur.com/IJfmdl9.png) In vscode L directory which has all the Learn near repository. ![](https://i.imgur.com/07u02IB.png) Starting with package.json to sort out two things one is scripts with a list of things able to do.some commands are: In `dev` command the `nodemon`(node monitor) is only watching extention type script and rerun it. In`npm start` the app is starting and then it source the dev account by dev account folder. In `prestart `command you can build the contract and debug, and dev deploy contract. devDependencies ![](https://i.imgur.com/tFhfvLh.png) ![](https://i.imgur.com/bkpPDIx.png) Even its vanilla javascripts its using parcel which is a bundler like webpack when its broken So this dev dependencies are used locally in running production all its need is near-api-js for targeting older browser like compiling new javascript features to support in older browsers requires this dependencies. Now looking into app how it works? ![](https://i.imgur.com/pjvbTlu.png) so, with this app you can change the greeting of page by adding value to change greeting box and save it.Even it tells you were to look at. source index html--> index.js --> its vanilla javascripts with check utils.js its all used to setup near-api-js ![](https://i.imgur.com/FjGfozZ.png) --- ## contracts are more secure so its not easy to check? But its not the best security model in general the contract should be secure even when every one look the source code. --- ## create-near-app is not best for creating Create-near-app is not suggested way to create a apps the more common way is to copy an existing project and modify to you needs like learn near app examples. > The part of complexity is to use all framework you can use vue,react,vanilla and even angular(but some buggy to use). > Using next.js will do ssg (static site generation) but you need to know which pieces to avoid. --- ###### tags: `bootcamp transcripts`