bitpro가 원문에서 글자만 모은 내용이에요. 표·그림·수식은 빠지거나 깨질 수 있어요. 전체 75쪽 중 23쪽
--rpc-url https://testnet-rpc.monad.xyz \
--private-key $PRIVATE_KEY
```
That is a working collection. From here you can swap in an allowlist, a public mint price, or a batch-mint standard like ERC-721A, and wire in the tooling below.
## Choose your tooling
Everything an NFT project needs is live on Monad. Pick per layer.
### Minting and launchpads
No-code tools to create, deploy, and manage a collection:
* **[Scatter](https://www.scatter.art/)**: artist-first launchpad that deploys fully-owned ERC-721A/1155 collections through low-fee contract factories.
* **[thirdweb](https://thirdweb.com)**: prebuilt Drop contracts and a claim UI.
### Marketplaces
List and trade on marketplaces live on Monad:
* **[OpenSea](https://opensea.io)**: including SeaDrop for primary mints.
* **[Scatter](https://www.scatter.art/)**: buy and sell collections, compatible with other NFT marketplaces.
### Indexing and NFT APIs
Read balances, ownership, metadata, and transfer history without running your own indexer, with providers like Rarible and thirdweb Insight. See [Indexers](/tooling-and-infra/indexers) for the full list and for building custom transfer indexes.
### Wallets and onboarding
Embedded wallets and account abstraction let users mint with an email or social login. With smart accounts and a paymaster you can sponsor **gasless mints**. See [Wallet infrastructure](/tooling-and-infra/wallet-infra).
### Randomness (fair mints and reveals)
For provably fair mint order and trait reveals, use a verifiable random function (VRF). See [Oracles](/tooling-and-infra/oracles).
### Token-bound accounts (ERC-6551)
The canonical Tokenbound stack (registry, account proxy, and implementation) is deployed on Monad at the same addresses as every other EVM chain, so the SDK's default flow works out of the box. See [Get started with ERC-6551](/guides/erc-6551).
### Metadata and storage
Metadata works the same as anywhere on EVM: point `tokenURI` at a stable location. For decentralized permanence, pin your files and JSON to IPFS or Arweave (for example Pinata, thirdweb Storage, or Irys) and reference them with `ipfs://` URIs. Freeze metadata once revealed so collectors can trust it will not change.
## What minting costs
Minting on Monad is efficient. A mint costs its gas usage times the network [base fee](/developer-essentials/gas-pricing) (typically about 100 gwei), paid in MON:
```
total cost (MON) = number of NFTs x gas per mint x base fee
```
Typical gas per mint:
* Gas-optimized batch mint (ERC-721A): about 40,000 gas
* Standard ERC-721 mint: about 85,000 gas
Use the estimator to size a specific drop. It computes cost in MON from the gas and base fee, which is always accurate, and can pull the live MON price for an optional USD figure.
<MintCostCalculator />
At a base fee of 100 gwei, minting out a full 10,000-item collection uses on the order of 40 to 85 MON in total gas, and deploying the contract is a one-time cost of roughly 0.25 MON. Each individual mint costs a negligible amount, which is what makes large drops, open editions, and fully onchain art practical on Monad. If you sponsor gas with a paymaster, the team covers this small amount instead of the minter.
## Resources
* [Get started with ERC-6551 (Token-Bound Accounts)](/guides/erc-6551)
* [Indexers](/tooling-and-infra/indexers)
* [Wallet infrastructure](/tooling-and-infra/wallet-infra)
* [Oracles](/tooling-and-infra/oracles)
* [OpenZeppelin Contracts](https://docs.openzeppelin.com/contracts)
* [ERC-721A](https://github.com/chiru-labs/ERC721A)
## Need help?
Join the [Monad Developer Discord](https://discord.gg/monaddev).
# Deploy a smart contract on Monad using Foundry
Source: https://docs.monad.xyz/guides/deploy-smart-contract/foundry
This guide uses the official [Foundry](/tooling-and-infra/toolkits/foundry) v1.8 or later to compile and deploy a contract on Monad Testnet.
## 1. Install Foundry
Install the official Foundry installer:
```sh theme={null}
curl -L https://foundry.paradigm.xyz | bash
```
Follow the installer instructions to add `foundryup` to your shell, then install the latest stable release:
```sh theme={null}
foundryup
```
Confirm that `forge --version` reports v1.8.0 or later. See the [Foundry toolkit page](/tooling-and-infra/toolkits/foundry#installation) for more installation and migration guidance.
## 2. Create a new foundry project
<Tip>
You can use `foundry-monad` template to create a new project.
*[Foundry-Monad](https://github.com/monad-developers/foundry-monad) is a Foundry template with Monad configuration.*
</Tip>
The below command uses `foundry-monad` to create a new foundry project:
```sh theme={null}
forge init --template monad-developers/foundry-monad [project_name]
```
Alternatively, you can create a foundry project using the command below:
```sh theme={null}
forge init [project_name]
```
## 3. Modify Foundry configuration
Update `foundry.toml` to select the Monad execution environment and configure Monad Testnet:
```toml lines title="foundry.toml" theme={null}
[profile.default]
src = "src"
out = "out"
libs = ["lib"]
network = "monad"
# Monad Testnet Configuration
eth-rpc-url = "https://testnet-rpc.monad.xyz"
chain_id = 10143
```
The `network = "monad"` setting is the persistent equivalent of passing `--network monad`. It makes Forge use Monad's execution rules for local compilation, testing, scripts, and transaction simulation. Foundry selects the active hardfork automatically when interacting with Monad Testnet.
## 4. Write a smart contract
You can write your smart contracts under the `src` folder. There is already a `Counter` contract in the project located at `src/Counter.sol`.
```solidity lines title="src/Counter.sol" theme={null}
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;
contract Counter {
uint256 public number;
function setNumber(uint256 newNumber) public {
number = newNumber;
}
function increment() public {
number++;
}
}
```
## 5. Compile the smart contract
```sh theme={null}
forge compile
```
Compilation process output can be found in the newly created `out` directory, which includes contract ABI and bytecode.
## 6. Deploy the smart contract
<Note>
For deploying contracts, we recommend using keystores instead of private keys.
</Note>
### Get testnet funds
Deploying smart contracts requires testnet funds. Claim testnet funds via a [faucet](https://testnet.monad.xyz).
### Deploy smart contract
<Tabs>
<Tab title="Using a Keystore (Recommended)">
Using a keystore is much safer than using a private key because keystore encrypts the private key and can later be referenced in any commands that require a private key.
Create a new keystore by importing a newly generated private key with the command below.
```sh theme={null}
cast wallet import monad-deployer --private-key $(cast wallet new | grep 'Private key:' | awk '{print $3}')
```
Here is what the command above does, step by step:
* Generates a new private key
* Imports the private key into a keystore file named `monad-deployer`
* Prints the address of the newly created wallet to the console
After creating the keystore, you can read its address using:
```sh theme={null}
cast wallet address --account monad-deployer
```
Provide a password to encrypt the keystore file when prompted and do not forget it.
Run the below command to deploy your smart contracts
```sh theme={null}
forge create src/Counter.sol:Counter --account monad-deployer --broadcast
```
</Tab>
<Tab title="Using a Private Key (Not Recommended)">
Use the below command to deploy a smart contract by directly pasting the private key in the terminal.
<Warning>
Using a private key is not recommended. You should not be copying and pasting private keys into your terminal. Please use a keystore instead.
</Warning>
```sh theme={null}
forge create --private-key <your_private_key> src/Counter.sol:Counter --broadcast
```
</Tab>
</Tabs>
On successful deployment of the smart contract, the output should be similar to the following:
```sh theme={null}
[⠊] Compiling...
Deployer: 0xB1aB62fdFC104512F594fCa0EF6ddd93FcEAF67b
Deployed to: 0x67329e4dc233512f06c16cF362EC3D44Cdc800e0
Transaction hash: 0xa0a40c299170c9077d321a93ec20c71e91b8aff54dd9fa33f08d6b61f8953ee0
```
### Next Steps
Check out [how to verify the deployed smart contract on MonadVision](/guides/verify-smart-contract/foundry).
# Deploy a smart contract on Monad using Hardhat
Source: https://docs.monad.xyz/guides/deploy-smart-contract/hardhat
[Hardhat](https://hardhat.org/docs) is a comprehensive development environment consisting of different components for editing, compiling, debugging, and deploying your smart contracts.
## Requirements
Before you begin, install a Node.js version supported by your Hardhat version:
* Hardhat 2: Node.js v20.0.0 or later
* Hardhat 3: Node.js v22.13.0 or later
<Note>
If you are on Windows, we strongly recommend using [WSL 2](https://learn.microsoft.com/en-us/windows/wsl/about) when following this guide.
</Note>
<Warning>
When deploying to Monad, set `evmVersion: "osaka"` in your Hardhat Solidity compiler settings. For example:
```ts theme={null}
solidity: {
settings: {
evmVersion: "osaka",
},
},
```
</Warning>
<Tabs>
<Tab title="Hardhat 2">
## 1. Create a new Hardhat project
<Tip>
You can use the `hardhat-monad` template to create a new project with Monad configuration already set up.
*[hardhat-monad](https://github.com/monad-developers/hardhat-monad) is a Hardhat template with Monad configuration.*
</Tip>
Clone the repository to your machine using the command below:
```sh theme={null}
git clone https://github.com/monad-developers/hardhat-monad.git
cd hardhat-monad
```
## 2. Install dependencies
```sh theme={null}
npm install
```
## 3. Create an .env file
```sh theme={null}
cp .env.example .env
```
Edit the `.env` file with your private key:
```
PRIVATE_KEY=your_private_key_here
```
<Warning>
Protect your private key carefully. Never commit it to version control, share it in public repositories, or expose it in client-side code. Your private key provides full access to your funds.
</Warning>
## 4. Deploy the smart contract
The following commands use [Hardhat Ignition](https://hardhat.org/ignition/docs/getting-started#overview):
### Deploying to the local hardhat node
Run hardhat node by running:
```bash theme={null}
npx hardhat node
```
To deploy the example contract to the local hardhat node, run the following command in a separate terminal:
```bash theme={null}
npx hardhat ignition deploy ignition/modules/Counter.ts
```
### Deploying to Monad Testnet
Ensure your private key is set in the `.env` file.
Deploy the contract to Monad Testnet:
```bash theme={null}
npx hardhat ignition deploy ignition/modules/Counter.ts --network monadTestnet
```
Redeploy the same code to a different address:
```bash theme={null}
npx hardhat ignition deploy ignition/modules/Counter.ts --network monadTestnet --reset
```
### Deploying to Monad Mainnet
Ensure your private key is set in the `.env` file.
Deploy the contract to Monad Mainnet:
```bash theme={null}
npx hardhat ignition deploy ignition/modules/Counter.ts --network monadMainnet
```
Redeploy the same code to a different address:
```bash theme={null}
npx hardhat ignition deploy ignition/modules/Counter.ts --network monadMainnet --reset
```
</Tab>
<Tab title="Hardhat3">
## 1. Create a new Hardhat3 project
<Tip>
You can use the `hardhat3-monad` template to create a new project with Monad configuration already set up for Hardhat3.
*[hardhat3-monad](https://github.com/monad-developers/hardhat3-monad) is a Hardhat3 template with Monad configuration.*
To learn more about Hardhat3, please visit the [Getting Started guide](https://hardhat.org/docs/getting-started#getting-started-with-hardhat-3).
</Tip>
Clone the repository to your machine using the command below:
```sh theme={null}
git clone https://github.com/monad-developers/hardhat3-monad.git
cd hardhat3-monad
```
## 2. Install dependencies
```sh theme={null}
npm install
```
## 3. Set up your private key
Create a `.env` file in the project root:
```sh theme={null}
PRIVATE_KEY=your_private_key_here
ETHERSCAN_API_KEY=your_etherscan_api_key_here
```
<Warning>
Protect your private key carefully. Never commit your `.env` file or expose your private key. Your private key provides full access to your funds.
</Warning>
## 4. Deploy the smart contract
The following commands use [Hardhat Ignition](https://hardhat.org/ignition/docs/getting-started#overview):
### Deploying to a local chain
```bash theme={null}
npx hardhat ignition deploy ignition/modules/Counter.ts
```
### Deploying to Monad Testnet
Ensure your `.env` file is set up with your private key.
```bash theme={null}
npx hardhat ignition deploy ignition/modules/Counter.ts --network monadTestnet
```
### Deploying to Monad Mainnet
Ensure your `.env` file is set up with your private key.
```bash theme={null}
npx hardhat ignition deploy ignition/modules/Counter.ts --network monadMainnet
```
</Tab>
</Tabs>
## Next Steps
Check out [how to verify the deployed smart contract on MonadVision](/guides/verify-smart-contract/hardhat).
# Deploy a Contract
Source: https://docs.monad.xyz/guides/deploy-smart-contract/index
<CardGroup>
<Card title="Foundry" href="/guides/deploy-smart-contract/foundry">
Deploy a smart contract on Monad using Foundry
</Card>
<Card title="Hardhat" href="/guides/deploy-smart-contract/hardhat">
Deploy a smart contract on Monad using Hardhat
</Card>
<Card title="Remix" href="/guides/deploy-smart-contract/remix">
Deploy a smart contract on Monad using Remix
</Card>
</CardGroup>
# Deploy a smart contract on Monad using Remix
Source: https://docs.monad.xyz/guides/deploy-smart-contract/remix
[Remix IDE](https://remix.ethereum.org/) is a browser-based IDE that can be used for the entire journey of smart contract development by users at every knowledge level. It requires no setup, fosters a fast development cycle, and has a rich set of plugins with intuitive GUIs.
In this guide you will learn how to deploy and interact with a simple Greeting smart contract on Monad Testnet using [Remix IDE](https://remix.ethereum.org/).
## Requirements
* You need to have the Monad Testnet network added to your wallet.
## Deploying the smart contract
Head over to [Remix IDE](https://remix.ethereum.org/) in your browser. Click 'Start Coding' to create a new project template.
<img alt="remix-ide" />
Make sure the 'contracts' folder is selected, then create a new file using the "Create new file" button on top left corner.
<img alt="create-file" />
Name the new file "Gmonad.sol" and add the following code to it
```solidity lines title="src/Gmonad.sol" theme={null}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;
contract Gmonad {
string public greeting;
constructor(string memory _greeting) {
greeting = _greeting;
}
function setGreeting(string calldata _greeting) external {
greeting = _greeting;
}
}
```
**Note:** You may see a red squiggly line underneath the `pragma solidity...` line; this is because the default compiler version is outside of the range specified in the contract. We'll fix that in the next step.
<img alt="code" />
Let's compile the smart contract. Navigate to the compiler view by clicking the "Solidity compiler" tab on the far left. Then select the right compiler version (0.8.24).
<img alt="compiler" />
Once you have the right compiler version selected, click on the "Compile Gmonad.sol" button. If succesful, you will see a green check mark on the "Solidity compiler" tab icon.
<img alt="compile" />
Now we can deploy the smart contract! Navigate to the deploy view using the "Deploy & run transactions" tab on the far left.
<img alt="deploy" />
Using the "Environment" dropdown, select "Injected Provider" to connect to your wallet.
The screenshot below says "Injected Provider - MetaMask"; in case you are using some wallet other than MetaMask you may see an appropriate option.
<img alt="environment" />
Your wallet should pop up asking for permission to connect to Remix, click "Connect".
<img alt="connect" />
Once connected you should be able to see your address with your balance in the "Account" dropdown.
Make sure you also see the correct chain id under the "Environment" dropdown.
Now let's deploy the contract. `Gmonad.sol` requires a greeting message to be passed to the constructor before it can be deployed; choose the greeting message of your choice (in this example it is "gmonad").
Now you can deploy the smart contract by clicking the "Deploy" button.
<img alt="deploy" />
You should see a wallet popup asking for confirmation to deploy the smart contract. Click "Confirm".
<img alt="confirm" />
Once the transaction is confirmed you will see the smart contract address in the "Deployed Contracts" section on the bottom left.
<img alt="deployed" />
## Interacting with the smart contract
You can expand the smart contract to see the functions available.
There you will find a `greeting` button which can be used to read the current greeting message stored in the smart contract.
Click the "greeting" button to call the `greeting()` method (which outputs the current greeting message). You'll need to click the expand arrow in the terminal output to see the decoded output.
<Info>
This "greeting" button is a getter function which is automatically created for the *public* `greeting` state variable in the smart contract.
</Info>
<img alt="expand" />
You can change the greeting message by using the `setGreeting` function.
In this example, we will change the greeting message to "gmonad molandak".
Once again, click the "transact" button to initiate the transaction.
You should see a wallet popup asking for confirmation to change the greeting message. Click "Confirm".
<img alt="transact" />
Once the transaction is confirmed you can view the updated greeting message using the `greeting` button.
<img alt="updated" />
Congratulations! You have successfully deployed and interacted with a smart contract on Monad Testnet using Remix IDE.
# EVM Behavior
Source: https://docs.monad.xyz/guides/evm-resources/evm-behavior
## EVM Behavioral Specification
* [Notes on the EVM](https://github.com/CoinCulture/evm-tools/blob/master/analysis/guide.md): straightforward technical specification of the EVM plus some behavioral examples
* [EVM: From Solidity to bytecode, memory and storage](https://www.youtube.com/watch?v=RxL_1AfV7N4): a 90-minute talk from Peter Robinson and David Hyland-Wood
* [EVM illustrated](https://takenobu-hs.github.io/downloads/ethereum_evm_illustrated.pdf): an excellent set of diagrams for confirming your mental model
* [EVM Deep Dives: The Path to Shadowy Super-Coder](https://noxx.substack.com/p/evm-deep-dives-the-path-to-shadowy)
## Opcode Reference
<Note>
Opcode pricing on Monad has been changed to reflect their relative costs in execution, learn more about it [here](/developer-essentials/opcode-pricing)
</Note>
[evm.codes](https://www.evm.codes/): opcode reference and an interactive sandbox for stepping through bytecode execution
## Solidity Storage Layout
The EVM allows smart contracts to store data in 32-byte words ("storage slots"), however the details of how complex datastructures such as lists or mappings is left as an implementation detail to the higher-level language. Solidity has a specific way of assigning variables to storage slots, described below:
* [Official docs on storage layout](https://docs.soliditylang.org/en/latest/internals/layout_in_storage.html)
* [Storage patterns in Solidity](https://programtheblockchain.com/posts/2018/03/09/understanding-ethereum-smart-contract-storage/)
# EVM Resources
Source: https://docs.monad.xyz/guides/evm-resources프로젝트로 돌아가기