Contract Deployment Tutorial
The RISE Testnet allows developers to deploy and test smart contracts. This tutorial will walk you through deploying contracts using popular Ethereum development tools.
Prerequisites
Before starting:
- Get testnet ETH (see Getting Testnet ETH)
- Install Node.js and a package manager (npm/yarn)
- Have a wallet with your private key ready
Getting Testnet ETH
You'll need testnet ETH to deploy contracts. You can:
- Contact the RISE team through the builder form or join our Builder Discord
- Use the testnet faucet (coming soon)
Deploy with Hardhat
1. Set Up Project
bash
# Create new directory
mkdir my-rise-contract
cd my-rise-contract
# Initialize project
npm init -y
npm install --save-dev hardhat @nomicfoundation/hardhat-toolbox
npx hardhat init
2. Configure Hardhat
Create or modify hardhat.config.js
:
javascript
require("@nomicfoundation/hardhat-toolbox");
/** @type import('hardhat/config').HardhatUserConfig */
module.exports = {
solidity: "0.8.24",
networks: {
rise: {
url: process.env.RISE_RPC_URL,
accounts: [process.env.PRIVATE_KEY],
chainId: 11155931
}
}
};
3. Create Contract
Create contracts/Lock.sol
:
solidity
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.24;
contract Lock {
uint public unlockTime;
address payable public owner;
constructor(uint _unlockTime) payable {
require(block.timestamp < _unlockTime, "Unlock time should be in future");
unlockTime = _unlockTime;
owner = payable(msg.sender);
}
function withdraw() public {
require(block.timestamp >= unlockTime, "Too early");
require(msg.sender == owner, "Not owner");
owner.transfer(address(this).balance);
}
}
4. Deploy Contract
Create scripts/deploy.js
:
javascript
async function main() {
const currentTimestampInSeconds = Math.round(Date.now() / 1000);
const unlockTime = currentTimestampInSeconds + 60; // 1 minute from now
const Lock = await ethers.getContractFactory("Lock");
const lock = await Lock.deploy(unlockTime, { value: ethers.parseEther("0.0001") });
await lock.waitForDeployment();
console.log(
`Lock with ${ethers.formatEther("0.0001")} ETH deployed to ${lock.target}`
);
}
main().catch((error) => {
console.error(error);
process.exitCode = 1;
});
Deploy:
bash
npx hardhat run scripts/deploy.js --network rise
Deploy with Foundry
1. Install Foundry
bash
curl -L https://foundry.paradigm.xyz | bash
foundryup
2. Create Project
bash
forge init my-rise-contract
cd my-rise-contract
3. Deploy Contract
bash
forge create \
--rpc-url RPC_URL \
--private-key YOUR_PRIVATE_KEY \
src/Lock.sol:Lock \
--constructor-args 1706745600 \
--value 0.0001ether
Replace 1706745600
with a future Unix timestamp and adjust the ETH value as needed.
Verify Your Contract
After deployment, verify your contract following our Contract Verification Guide.
Need Help?
- Join our Builder Discord for developer support
- Submit issues on our GitHub
- Contact us through the builder form