Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the use of NeoRay 2.0

2025-03-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

It is believed that many inexperienced people don't know what to do about the use of NeoRay 2.0. therefore, this article summarizes the causes and solutions of the problem. Through this article, I hope you can solve this problem.

Preface

NeoRay is a tool launched by the NEL community to facilitate NEO developers to develop contracts. Since the launch of this tool, it has been praised by many developers and greatly facilitated the vast number of NEO contract developers. I have also been using this tool for NEO contract development and debugging.

Recently, NEL launched a new version of NeoRay, increased the contract development of the python language, and humanized some operation procedures. As an enthusiast of NEO contract development, I can't wait to taste something fresh. The experience is good, the page looks simpler and clearer, and the contract invocation part is more user-friendly.

As the new version is different from the old version, the changes are still very big, and the pages and processes are very different. As a newcomer, it is still necessary to record the tasting process and experience, so as to facilitate the experience of the newcomers.

Body 0x01 login

Instead of directly using the private key or nep6 wallet login for contract deployment and invocation, NeoRay2.0 uses the TEEMO plug-in wallet, a product previously launched by the NEL community. You need to install the plug-in wallet before using NeoRay2.0. Otherwise, the following prompt appears:

Here is an introduction to the Teemo plug-in wallet: portal.

Introduction to the function of 0x02 page

The overall page of the new version of NeoRay is as follows, with five function buttons on the left: file browsing, contract deployment, contract invocation, contract debugging, and support. It also provides the ability to switch back to the old version of NeoRay.

0x03 writes or loads contract documents

In the file browsing module, there are three ways to import a contract file. The first is to add local files, the second is to create new files to write directly online, and the remaining one is to load contracts deployed by other developers through the contract hash. You can make a reasonable choice according to your needs. Here we will use the first way to do the demonstration. In the following figure, I imported a local test contract:

0x04 deployment contract

When the contract is written or imported, we need to compile and release the contract. Click the contract deployment button on the left to go to the deployment page, and first click the compile button. If the contract is written correctly, the output box below will display the contract hash. If there is an error in the contract, the compilation will be prompted to fail. At present, the reason for the failure is not detailed enough. I hope that the reason for the failure can be improved in the subsequent updates.

Set some parameters when deploying the contract. "dynamic invocation" refers to whether there is a situation in the contract that invokes a variable contract, such as calling contract B but contract B cannot specify its hash value when the contract is issued, then the function needs to be called dynamically. "create storage area" refers to the storage function used by the contract. "acceptable payment" refers to whether the contract can accept another address to transfer assets.

It should be noted that different parameter choices will lead to different charges. Currently, "dynamic invocation" will increase the cost of 500gas, and "create storage" will increase the cost of 400gas.

After clicking the deploy contract button, Teemo Wallet will pop up to ask for a signature. Click "agree".

0x05 contract call

Wait for the transaction of the deployment contract to be confirmed through Teemo Wallet

After the transaction is confirmed, click the contract call button on the left side of the NeoRay2.0 to come to the contract debugging module. Next, I will introduce the meaning and usage of some parameters under this module.

System fee: the calling contract on the neo common chain is charged according to the instructions called. Although there is a free quota for 10gas, some complex operations may exceed the limit for 10gas. So if the contract you call is so complex that the cost exceeds the 10gas, you need to fill in the amount you exceeded. Handling fee price list

Network fee: the latest charging rules require an additional handling fee for transactions exceeding 1024 bytes. Teemo will automatically add the network fee. So this place just defaults to zero.

The transaction comes with a Gas: if you need to transfer a gas to the calling contract, fill in the specific amount at this place.

Add parameters: the parameters for general contracts are of the type (string,object []). So the first added parameter selects the string type, and the second selects the array type. If your contract is different, choose the appropriate type according to the parameter type of your contract.

Give me a few simple examples.

1. If your contract is Main (int a), then parameter one is Integer and parameter two is not required.

two。 If your contract is Main (int a, int b), then parameter one is Integer and parameter two is Integer.

Ps: the Address type is "AWKqEmC1HsC4uBDvaoh6JLtQ2rigMdRSwX", and the NeoRay will be internally converted to byte []. If you do not understand the choice of the corresponding parameters, you can take a look at the corresponding posts in the forum. Portal

Call contract and trial run: invoking a contract means sending a transaction on the chain, which will change the data on the chain. A trial run means simulating the execution of the contract and does not cause changes to the data on the chain.

Next, based on the contract we previously deployed, we will demonstrate the trial run of three examples:

The first example is as follows. Once the parameter is filled in "Hello", the return is "ByteArray", and the conversion is "World". Common conversion tools: portals

The second example is as follows. Enter "return" in parameter 1 and the number 2 in the first digit of the array in parameter 2:

The third example is as follows. Enter "add" in parameter 1:

Next, we use the parameters of the third example to send the calling transaction. Teemo Wallet will pop up a pop-up box and ask for a signature. After the transaction is issued, wait for the transaction to be confirmed.

0x06 contract debugging

After a transaction that invokes the contract is confirmed, you can click the contract debugging button to debug the contract. This function is mainly to observe the execution process of the contract to find the problem of the contract when the execution result of the contract is not in line with the expectation.

It is important to note that you must choose the correct contract you want to debug. Because only the current wallet address calls the transaction of this contract will be displayed in the transaction list.

If a transaction is confirmed on the chain but the corresponding transaction is not displayed on this page, please wait a few seconds or switch the function module, and try not to refresh the page.

After selecting a transaction, you can debug. The following picture shows the instruction process executed by this call. The execution process of the contract can be observed through the up and down buttons of the keyboard. Through notify, you can get the return value of the transaction, as well as the notice of the contract being sold. If necessary, you can debug the contract by throwing a notification, similar to the way you hit log when debugging. You can observe the data stored in the evaluation stack and temporary stack in the CalcStack&AltStack in the lower right corner.

Through the instructions executed on the left and the contract code on the right, you can observe which line of code the contract is executed to report an error. Or perform some wrong process. Convenient for developers to debug.

0x07 support

There are some navigation for the NEL community and the ability to request gas in the support function module.

After reading the above, have you mastered how to use NeoRay 2.0? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report