# How to use the Solidity compiler with TestRPC blockchain emulator

**URL:** <https://forum.soliditylang.org/t/how-to-use-the-solidity-compiler-with-testrpc-blockchain-emulator/356>\
**Category:** Tools & Infrastructure\
**Created:** [June 28, 2021, 1:08pm UTC](https://forum.soliditylang.org/t/how-to-use-the-solidity-compiler-with-testrpc-blockchain-emulator/356 "2021-06-28T13:08:34Z")\
**Posts on this page:** 19\
**Page:** 1

<div class="post-metadata">

**Author:** ![alwi79asma84](https://avatars.discourse-cdn.com/v4/letter/a/2bfe46/32.png) [@alwi79asma84](https://forum.soliditylang.org/u/alwi79asma84)\
**Post date:** [June 28, 2021, 1:08pm UTC](https://forum.soliditylang.org/t/how-to-use-the-solidity-compiler-with-testrpc-blockchain-emulator/356/1 "2021-06-28T13:08:34Z")

</div>

I want to interact with my QT application which include a solidity file written in version 0.4.0 , with Testrpc as ablockchain 6.0.3 but I don’t know which version this emulator accept , any one can help me please ,

---

<div class="post-metadata">

**Author:** ![cameel](https://sea1.discourse-cdn.com/flex001/user_avatar/forum.soliditylang.org/cameel/32/34_2.png) [@cameel](https://forum.soliditylang.org/u/cameel)\
**Post date:** [June 28, 2021, 1:42pm UTC](https://forum.soliditylang.org/t/how-to-use-the-solidity-compiler-with-testrpc-blockchain-emulator/356/2 "2021-06-28T13:42:41Z")

</div>

If you want to compile a file written for 0.4.0 than any version between 0.4.0 and 0.4.26 should work (You might need to adjust the version pragma though if it says exactly `0.4.0` rather than `^0.4.0`).

[TestRPC](https://docs.nethereum.com/en/latest/ethereum-and-clients/test-rpc/) states this about the compiler when listing commands:

> eth\_compileSolidity: If you’d like Solidity compilation in Javascript, please see the solc-js project. Docker.

So I suspect you just need to install `solc` package via `npm` (that’s the name for `solc-js` in npm registry) and use the configuration to tell it which version to use.

---

<div class="post-metadata">

**Author:** ![alwi79asma84](https://avatars.discourse-cdn.com/v4/letter/a/2bfe46/32.png) [@alwi79asma84](https://forum.soliditylang.org/u/alwi79asma84)\
**Post date:** [June 28, 2021, 1:52pm UTC](https://forum.soliditylang.org/t/how-to-use-the-solidity-compiler-with-testrpc-blockchain-emulator/356/3 "2021-06-28T13:52:42Z")

</div>

I there is a chance to try this in your machine the project is in [GitHub - MohamedTaharHAMMI/BubblesOfTrust-BBTrust-](https://github.com/MohamedTaharHAMMI/BubblesOfTrust-BBTrust-)  
I was install solc and I check the version which is 0.5.16 and I convert the old one but the project sill stopped when opening the solidity file

---

<div class="post-metadata">

**Author:** ![alwi79asma84](https://avatars.discourse-cdn.com/v4/letter/a/2bfe46/32.png) [@alwi79asma84](https://forum.soliditylang.org/u/alwi79asma84)\
**Post date:** [June 28, 2021, 2:32pm UTC](https://forum.soliditylang.org/t/how-to-use-the-solidity-compiler-with-testrpc-blockchain-emulator/356/4 "2021-06-28T14:32:50Z")

</div>

solc --version  
solc, the solidity compiler commandline interface  
Version: 0.5.16+commit.9c3226ce.Linux.g++  
but this is the solc but now I want to use Testrpc to stored my contract , so the problem id du to the Testrpc it self

---

<div class="post-metadata">

**Author:** ![cameel](https://sea1.discourse-cdn.com/flex001/user_avatar/forum.soliditylang.org/cameel/32/34_2.png) [@cameel](https://forum.soliditylang.org/u/cameel)\
**Post date:** [June 28, 2021, 4:23pm UTC](https://forum.soliditylang.org/t/how-to-use-the-solidity-compiler-with-testrpc-blockchain-emulator/356/5 "2021-06-28T16:23:14Z")

</div>

What you have is the native Linux binary. TestRPC docs say they use solc-js, which is this: [GitHub - ethereum/solc-js: Javascript bindings for the Solidity compiler](https://github.com/ethereum/solc-js). You can install it with `npm install solc`.

---

<div class="post-metadata">

**Author:** ![alwi79asma84](https://avatars.discourse-cdn.com/v4/letter/a/2bfe46/32.png) [@alwi79asma84](https://forum.soliditylang.org/u/alwi79asma84)\
**Post date:** [June 28, 2021, 2:06pm UTC](https://forum.soliditylang.org/t/how-to-use-the-solidity-compiler-with-testrpc-blockchain-emulator/356/6 "2021-06-28T14:06:34Z")

</div>

This testrpc version is used thereumJS TestRPC v6.0.3 (ganache-core: 2.0.2)

---

<div class="post-metadata">

**Author:** ![alwi79asma84](https://avatars.discourse-cdn.com/v4/letter/a/2bfe46/32.png) [@alwi79asma84](https://forum.soliditylang.org/u/alwi79asma84)\
**Post date:** [June 28, 2021, 5:28pm UTC](https://forum.soliditylang.org/t/how-to-use-the-solidity-compiler-with-testrpc-blockchain-emulator/356/7 "2021-06-28T17:28:05Z")

</div>

Yes, I was install the same one but the project still not worked , really I want your help

---

<div class="post-metadata">

**Author:** ![cameel](https://sea1.discourse-cdn.com/flex001/user_avatar/forum.soliditylang.org/cameel/32/34_2.png) [@cameel](https://forum.soliditylang.org/u/cameel)\
**Post date:** [June 28, 2021, 6:03pm UTC](https://forum.soliditylang.org/t/how-to-use-the-solidity-compiler-with-testrpc-blockchain-emulator/356/8 "2021-06-28T18:03:11Z")

</div>

Looking at your README, you’re using [GitHub - trufflesuite/ganache-cli-archive: Fast Ethereum RPC client for testing and development. See https://github.com/trufflesuite/ganache for current development.](https://github.com/ethereumjs/testrpc) which actually redirects to [ganache-cli](https://github.com/trufflesuite/ganache-cli). Looks like the project became Ganache:

> ### Looking for TestRPC?
> 
> If you came here expecting to find the TestRPC, you’re in the right place! Truffle has taken the TestRPC under its wing and made it part of the Truffle suite of tools. From now on you can expect better support along with tons of new features that help make Ethereum development safer, easier, and more enjoyable. Use `ganache-cli` just as you would `testrpc`.

And Ganache does not support Solidity compilation like TestRPC used to:

> ## Unsupported Methods
> 
> - `eth_compileSolidity`: If you’d like Solidity compilation in Javascript, please see the [solc-js project](https://github.com/ethereum/solc-js).

This means it won’t work the way you’re trying to do it. You need to use the compiler yourself and compile the contract into bytecode you can deploy.

If you can use JS directly from Qt, try solc-js. If not, you can invoke the native Linux binary you got with `--standard-json` option. Here’s the documentation for the input JSON the compiler accepts: [Using the compiler \> Input description](https://docs.soliditylang.org/en/latest/using-the-compiler.html#input-description).

And an example of input and compiler invocation:

`input.json`:

```auto
{
    "language": "Solidity",
    "sources": {
        "contract.sol": {
            "content": "contract C {}"
        }
    },
    "settings": {
        "outputSelection": {"*": { "*": ["evm.bytecode.object"]}},
        "optimizer": {"enabled": true}
    }
}

```

```auto
solc --standard-json input.json

```

---

<div class="post-metadata">

**Author:** ![alwi79asma84](https://avatars.discourse-cdn.com/v4/letter/a/2bfe46/32.png) [@alwi79asma84](https://forum.soliditylang.org/u/alwi79asma84)\
**Post date:** [June 28, 2021, 6:14pm UTC](https://forum.soliditylang.org/t/how-to-use-the-solidity-compiler-with-testrpc-blockchain-emulator/356/9 "2021-06-28T18:14:08Z")

</div>

I was already install solc-js compiler but the emulator still doesn’t accept the solidity file , I was try much ways but no one success .

---

<div class="post-metadata">

**Author:** ![alwi79asma84](https://avatars.discourse-cdn.com/v4/letter/a/2bfe46/32.png) [@alwi79asma84](https://forum.soliditylang.org/u/alwi79asma84)\
**Post date:** [June 28, 2021, 6:23pm UTC](https://forum.soliditylang.org/t/how-to-use-the-solidity-compiler-with-testrpc-blockchain-emulator/356/10 "2021-06-28T18:23:18Z")

</div>

what section exactly in my project must be edited [[GitHub - MohamedTaharHAMMI/BubblesOfTrust-BBTrust-](https://github.com/MohamedTaharHAMMI/BubblesOfTrust-BBTrust-)]  
I want your help please

---

<div class="post-metadata">

**Author:** ![cameel](https://sea1.discourse-cdn.com/flex001/user_avatar/forum.soliditylang.org/cameel/32/34_2.png) [@cameel](https://forum.soliditylang.org/u/cameel)\
**Post date:** [June 28, 2021, 6:31pm UTC](https://forum.soliditylang.org/t/how-to-use-the-solidity-compiler-with-testrpc-blockchain-emulator/356/11 "2021-06-28T18:31:15Z")

</div>

Because the emulator no longer supports compiling Solidity files. Unfortunately you must compile the file yourself and give it already compiled bytecode.

---

<div class="post-metadata">

**Author:** ![alwi79asma84](https://avatars.discourse-cdn.com/v4/letter/a/2bfe46/32.png) [@alwi79asma84](https://forum.soliditylang.org/u/alwi79asma84)\
**Post date:** [June 28, 2021, 6:33pm UTC](https://forum.soliditylang.org/t/how-to-use-the-solidity-compiler-with-testrpc-blockchain-emulator/356/12 "2021-06-28T18:33:40Z")

</div>

how I can do that , help me please I want to complete the project as soon as possible

---

<div class="post-metadata">

**Author:** ![cameel](https://sea1.discourse-cdn.com/flex001/user_avatar/forum.soliditylang.org/cameel/32/34_2.png) [@cameel](https://forum.soliditylang.org/u/cameel)\
**Post date:** [June 28, 2021, 6:51pm UTC](https://forum.soliditylang.org/t/how-to-use-the-solidity-compiler-with-testrpc-blockchain-emulator/356/13 "2021-06-28T18:51:21Z")

</div>

Please look at my [post above](http://forum.soliditylang.org/t/how-to-use-the-solidity-compiler-with-testrpc-blockchain-emulator/356/8). I gave an example of how you can run the compiler. The details on how to integrate it with your project are up to you. Sorry, but I do not know your code at all and it’s really hard for me to give you a more specific answer.

---

<div class="post-metadata">

**Author:** ![alwi79asma84](https://avatars.discourse-cdn.com/v4/letter/a/2bfe46/32.png) [@alwi79asma84](https://forum.soliditylang.org/u/alwi79asma84)\
**Post date:** [June 29, 2021, 5:54pm UTC](https://forum.soliditylang.org/t/how-to-use-the-solidity-compiler-with-testrpc-blockchain-emulator/356/14 "2021-06-29T17:54:18Z")

</div>

what about this  
You do [need the source code,](https://ethereum.stackexchange.com/questions/1437/do-i-need-a-compiled-contract-just-to-get-the-abi-definition) as you have, and one way to get the ABI is to paste it in [Remix IDE](https://remix.ethereum.org/), compile it, and then click the ‘ABI’ button to copy the ABI into your clipboard.

---

<div class="post-metadata">

**Author:** ![cameel](https://sea1.discourse-cdn.com/flex001/user_avatar/forum.soliditylang.org/cameel/32/34_2.png) [@cameel](https://forum.soliditylang.org/u/cameel)\
**Post date:** [June 29, 2021, 9:10pm UTC](https://forum.soliditylang.org/t/how-to-use-the-solidity-compiler-with-testrpc-blockchain-emulator/356/15 "2021-06-29T21:10:25Z")

</div>

If you need contract ABI you can simply run

```auto
solc --abi <file name>.sol

```

---

<div class="post-metadata">

**Author:** ![alwi79asma84](https://avatars.discourse-cdn.com/v4/letter/a/2bfe46/32.png) [@alwi79asma84](https://forum.soliditylang.org/u/alwi79asma84)\
**Post date:** [June 30, 2021, 5:21am UTC](https://forum.soliditylang.org/t/how-to-use-the-solidity-compiler-with-testrpc-blockchain-emulator/356/16 "2021-06-30T05:21:27Z")

</div>

but I want to call this in a QT instead of this  
#define CONTRACT\_PATH “/home/asma/Downloads/BBTrust/BCTrustV2/contracts/BCTrustV2.sol”  
QVariantList params ;  
params.append(FileToString(CONTRACT\_PATH)) ;

---

<div class="post-metadata">

**Author:** ![alwi79asma84](https://avatars.discourse-cdn.com/v4/letter/a/2bfe46/32.png) [@alwi79asma84](https://forum.soliditylang.org/u/alwi79asma84)\
**Post date:** [June 30, 2021, 8:41am UTC](https://forum.soliditylang.org/t/how-to-use-the-solidity-compiler-with-testrpc-blockchain-emulator/356/17 "2021-06-30T08:41:49Z")

</div>

excuse me what this code will do exactly

---

<div class="post-metadata">

**Author:** ![alwi79asma84](https://avatars.discourse-cdn.com/v4/letter/a/2bfe46/32.png) [@alwi79asma84](https://forum.soliditylang.org/u/alwi79asma84)\
**Post date:** [June 30, 2021, 8:58am UTC](https://forum.soliditylang.org/t/how-to-use-the-solidity-compiler-with-testrpc-blockchain-emulator/356/18 "2021-06-30T08:58:17Z")

</div>

and what about truffle

---

<div class="post-metadata">

**Author:** ![hrkrshnn](https://sea1.discourse-cdn.com/flex001/user_avatar/forum.soliditylang.org/hrkrshnn/32/22_2.png) [@hrkrshnn](https://forum.soliditylang.org/u/hrkrshnn)\
**Post date:** [June 30, 2021, 9:29am UTC](https://forum.soliditylang.org/t/how-to-use-the-solidity-compiler-with-testrpc-blockchain-emulator/356/19 "2021-06-30T09:29:13Z")

</div>

You’ll probably get a better answer if you find the support channel for TestRPC tool or other tools that you are using. As such, this post might be out of topic for the forum.
