Developer Docs
AppGitHub
  • Welcome!
  • Smart contracts
    • Core
      • Introduction
      • Deep Dive
      • Smart Contract Reference
        • PWN Hub
          • Tags
        • PWN Config
        • PWN Vault
        • Loan Types
          • Simple Loan
        • Proposals
          • Simple Loan Proposal
            • Simple Proposal
            • List Proposal
            • Elastic Proposal
            • Elastic Chainlink Proposal
            • Dutch Proposal
        • PWN Utilized Credit
        • PWN LOAN
        • PWN Revoked Nonce
        • Peripheral Contracts
          • Acceptor Controller
            • World ID
          • State Fingerprint Computer
            • UniV3
            • Chicken Bonds
          • Pool Adapter
            • Aave
            • Compound
            • ERC4626
        • Miscellaneous
          • PWN Fee Calculator
          • PWN Signature Checker
          • PWN Errors
          • PWN Periphery
          • Timelock
    • PWN DAO
      • Governance
        • Optimistic
        • Token
      • Tokens
        • PWN
        • stPWN
        • vePWN
          • Stake
          • Power
          • Metadata
      • Epoch Clock
      • Miscellaneous
        • Errors
        • EpochPowerLib
    • Tools
      • PWN Safe
        • Architecture
        • Security considerations
        • Smart Contract Reference
          • PWN Safe Factory
          • ATR Module
            • Tokenized Asset Manager
            • Recipient Permission Manager
          • Whitelist
          • ATR Guard
            • Operators context
      • Token Bundler
      • PWN Deployer
    • Libraries
      • MultiToken
    • Contract Addresses
  • More documentation
    • PWN Docs
    • FAQ
    • Audits
    • Using PWN without front-end
  • Deprecated
    • PWN Beta
      • Architecture
      • PWN
        • Off-chain signed offer
        • Offer types
      • PWN Vault
      • PWN LOAN
Powered by GitBook
On this page
  • 1. Summary
  • 2. Important links
  • 3. Contract details
  • Features
  • Inherited contracts, implemented Interfaces and ERCs
  • Functions
  • View Functions
Edit on GitHub
  1. Smart contracts
  2. Tools

PWN Deployer

PreviousToken BundlerNextLibraries

Last updated 11 months ago

1. Summary

PWNDeployer.sol contract manages deployments of the PWN Protocol contracts. It uses the Open-Zeppelin library to deploy contracts with the same addresses on all chains.

2. Important links

3. Contract details

  • PWNDeployer.sol is written in Solidity version 0.8.16

Features

  • Deploy new contracts

  • For ownable contracts, the deployer can transfer ownership to a supplied address

  • Provides a function to compute an address of a contract is deployed

Inherited contracts, implemented Interfaces and ERCs

Functions

deploy

Overview

This function deploys a new contract with given salt.

This function takes two arguments supplied by the owner:

  • bytes32salt - Salt to use in the CREATE2 call

  • bytes memorybytecode - Encoded code for contract creation with included constructor arguments

Implementation

function deploy(bytes32 salt, bytes memory bytecode) external onlyOwner returns (address) {
    return Create2.deploy(0, salt, bytecode);
}
deployAndTransferOwnership

Overview

This function takes three arguments supplied by the owner:

  • bytes32salt - Salt to use in the CREATE2 call

  • addressowner - Address to transfer the ownership to

  • bytes memorybytecode - Encoded code for contract creation with included constructor arguments

Implementation

function deployAndTransferOwnership(bytes32 salt, address owner, bytes memory bytecode) external onlyOwner returns (address deployedContract) {
    deployedContract = Create2.deploy(0, salt, bytecode);
    Ownable(deployedContract).transferOwnership(owner);
}

View Functions

computeAddress

Overview

Computes the address of a contract that would be deployed with a given salt.

This function takes two arguments supplied by the caller:

  • bytes32salt - Salt that would be used in the CREATE2 call

  • bytes32bytecodeHash - Hash of the encoded code for contract creation with included constructor arguments

Implementation

function computeAddress(bytes32 salt, bytes32 bytecodeHash) external view returns (address) {
    return Create2.computeAddress(salt, bytecodeHash);
}

This function deploys a new contract with given salt and transfers ownership of the deployed contract to the supplied address. It is expected for the deployed contract to implement .

Ownable
Ownable
Create2
pwn_deployer/src/PWNDeployer.sol at main · PWNFinance/pwn_deployerGitHub
GitHub
Logo