// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;

contract Car {
    string public model;
    address public carAddr;

    constructor( string memory _model)  {
        model = _model;
        carAddr = address(this);

contract CarFactory {
    Car[] public cars;

    function create( string memory _model) public {
        Car car = new Car( _model);

    function create2( string memory _model, bytes32 _salt) public {
        Car car = (new Car){salt: _salt}( _model);


this is my smart contract in which CarFactory contract deploys the car contract so how i verify the source code for the car contract and which code I need to use

  • Where are you trying to deploy it? Are you using remix or a framework in VSCode? If you're using Foundry, they have a good explanation in their docs. book.getfoundry.sh/forge/deploying Commented Aug 14, 2023 at 14:14

1 Answer 1


In order to deploy your Car smart contract using your Car Factory contract, you would need to have already deployed your Car Factory. You can do this in multiple different ways, one solution would be using Foundry like @ChefAharoni suggested. To do so you will need a private key and an RPC URL. You can get one for free from providers such as Alchemy and Infura.

After getting both of these things, deploying your contract is as simple as running a command:

$ forge create --rpc-url <your_rpc_url> --private-key <your_private_key> src/MyContract.sol:MyContract

Foundry allows you to write your smart contract, test, and deploy script in Solidity, however, if you have any experience in Javascript there is a development framework for deploying smart contracts in Javascript/Typescript called Hardhat, or if you prefer Python there is one for you as well called Brownie.

Once your Car Factory contract is deployed, you can deploy new Car contracts by simply calling your create() and create2() functions.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.