0

I am learning Solidity.

I wrote solidity code using openzeppelin and compile it using solcjs.
It returns multiple bytecode for main.sol and imported other sol file.

should I deploy only bytecode for main.sol? (main.sol bytecode contains other sol files bytecode?)

I am not a native english speaker, so please forgive me my weird english.

pragma solidity ^0.8.0;

import "./contracts/token/ERC721/extensions/ERC721URIStorage.sol";
import "./contracts/utils/Counters.sol";
import "./contracts/access/Ownable.sol";

contract Name is ERC721URIStorage,Ownable {
    using Counters for Counters.Counter;
    Counters.Counter private _tokenIds;

    constructor() ERC721("Name", "name") {}

    function mint(address nftowner)
    public
    onlyOwner
    returns(uint256)
    {
        uint256 newItemId = _tokenIds.current();
        _mint(nftowner, newItemId);
        _setTokenURI(newItemId, "https://example.com");
        _tokenIds.increment();
        return newItemId;
    }
}
takumi
  • 1

3 Answers3

1

On remix select the main contract with your logic to deploy. It will deploy all the dependencies as well.

Id suggest installing the etherscan plugin and making an account on their website to get an etherscan API_KEY to verify your contracts easily.

enter image description here

enter image description here

Matt Jaf
  • 339
  • 2
  • 8
1

If you're not using framework like Hardhat or truffle then use remix injected web3 it's the easiest way to deploy

0

To deploy a smart contract, I recommend you use either Hardhat (if your familiar with JavaScript) or Foundry/Forge (which is in Solidity)

If you want to use Hardhat, you can create a deploy script in a JS file inside the scripts folder of your project:

const hardhat = require("hardhat"); 

async function main() {
  const Contract = await hardhat.ethers.getContractFactory("YourContract");
  const contract = await Contract.deploy();

  await contract.deployed();

  console.log(`Contract address: ${contract.address}`);
}

main().catch((error) => {
  console.error(error);
  process.exitCode = 1;
});

Then, you can run the script with this command:

npx hardhat run --network <your-network> scripts/deploy.js

And you can verify your contract on Etherscan with this command

npx hardhat verify --network <your-network> <contract-address>

Both commands require some configuration in the Hardhat config file. Check the article above or the documentation for more info!

sideshowbarker
  • 81,827
  • 26
  • 193
  • 197
0xAnthony
  • 36
  • 1