KeyfKapadokya Gezi Acentası

Ethereum: Using Abigen with a combined-Json option does nothing

As a developer working on Ethereum -related projects, it is not uncommon to have problems when trying to generate go binding through Abigen. In this article, we will go into the problem and explore possible solutions.

Question:

You have faced unexpected behavior while trying to use Abigen with the Combined-Json option:

`

Abigen-Combined- JSON Uniswapv2Priceoracle.json-PKG Abi -uniswapv2-Out Uniswapv2.Go Out Out

`

As expected, you did not face error messages. However, the Generated GO file does not have the expected structure.

Solution:

To solve this problem, let’s first understand what happens when we use abigen with a combined-json:

  • Option “Combined-Json” forces Abigen to generate a JSON object that combines all the files specified in the input directory.

  • If a combination-Json is used, the generated file will refer to individual files instead of the actual code.

Why is this happening:

In your case you use this command:

`Bash

Abigen-Combined- JSON Uniswapv2Priceoracle.json-PKG Abi -uniswapv2-Out Uniswapv2.Go Out Out

`

Uniswapv2Priceoracle.Json’s file is transferred to Abigen, but the team is not actually processed. Instead, a JSON object containing references to this file will be generated.

How to correct:

Ethereum: Using abigen with combined-json option generates nothing

To eliminate this problem, you need to make sure that the output directory is actually GO files, not just references to other files. Here are some possible solutions:

  • Moving Uniswapv2Priceoracle.json on the same directory as your main project:

If your project is structured in this way:

`Bash

Project/

Main.-

Uniswapv2priceoracle.json

`

You can move uniswapv2priceoracle.json in the same directory as in your file“ Main.Go:

Bash

Abigen uniswapv2priceoracle.json -pkg both -uniswapv2 -OUT Main.Go

`

  • Use a different output directory:

If you need to store the project, you can specify the generated Go file output directory:

`Bash

Abigen-Combined-Json/Road/to/Output/Directory/Uniswapv2Priceoracle.Json-PKG Abi -uniswapv2-Out Main.Go

`

3
Use Abigen with another input option:

Instead of using the Combined -Json, you can try to specify the” -target “option to tell Abigen what type of output generation:

`Bash

Abigen -target go -pkg both – -Type uniswapv2 uniswapv2priceoracle.json

`

In this case, the Generated GO file will have one “uniswapv2go” file that has no reference.

Conclusion:

To solve the problem of nothing generation using Abigen with a combination-Json, make sure the output directory is actually Go files, not just references to other files. It can be corrected by moving “uniswapv2priceoracle.json” to the same directory as your main project or using another output directory.

When doing these activities, you should be able to generate work Go binding for your Ethereum projects.

Bir yanıt yazın

E-posta adresiniz yayınlanmayacak. Gerekli alanlar * ile işaretlenmişlerdir

Open chat
Nasıl Yardımcı Olabilirim
Merhabalar nasıl yardımcı olabilirim?