Pharo
  • 🟢Getting Started
  • 🤝Meet Pharo
    • ❔Why Pharo
    • 🌪️Use Cases
    • 📐Architecture
  • ✨Protocol
    • 🎨Product Design
    • 💰Pricing Models
    • 🏛️Capitol Provision
    • 📊Risk Assessment
  • 🛣️Roadmap
  • ⁉️FAQs
  • Market Manager
    • 💹Creating a Pharo Market
    • 👩‍💼Managing a Market
  • Liquidity Provider
    • 🎯Selecting a Market
    • 💵Provide Liquidity
  • Cover Buyer
    • 🤔What it means to buy cover
    • 🔅Buy Cover
  • Governance
    • Overview
    • Process
      • 📄Writing A Proposal
    • Glossary
    • Adversarial Circumstances
    • Governance Reference
  • PHRO Token
    • Overview
    • 🪙Tokenomics
    • Staking
    • 📄Contracts
    • 🐪PHRO Distribution Speed
  • Guides
  • Beginners Guide to Voting
  • Setting Up Your Local Environment
    • Hardhat
    • Foundry
  • API Reference
    • Start Here Developer
  • Technical Reference
    • Litepaper
    • Smart Contracts Overview
    • Pharo SDK
    • Anubis
    • Obelisk
Powered by GitBook
On this page
  • Deployed Contracts
  • Audits
  • Methods
  • permit()
  • _nonces()
  • lock()
  • transferWithLock()
  • tokensLocked()
  • tokensLockedAtTime()
  • totalBalanceOf()
  • extendLock()
  • increaseLockAmount()
  • tokensUnlockable()
  • unlock()
  • getUnlockableTokens()

Was this helpful?

  1. PHRO Token

Overview

Overview of PHRO token

Deployed Contracts

Contract

Address and ABI's

PHRO Token

0xD49d31402723a885e5272903b7C02e8Dd571Ea36

Contracts

Address and ABI's

PHRO Token

0x...

Audits

Methods

Besides the standard ERC20 token features (transfer(), balanceOf(), allowance(), etc.), the following features are also available.

permit()

function permit(address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) external

Allows a use to permit another account (or contract) to use their funds using a signed message. This enables gas-less transactions and single approval/transfer transactions.

Parameter

Type

Description

owner

address

The owner of the funds

spender

address

The spender of the funds

value

uint256

The amount the spender is permitted to use

deadline

uint256

The deadline timestamp that the permit is valid. Use type(uint).max for no deadline.

v

uint8

Signature parameter

r

bytes32

Signature parameter

s

bytes32

Signature parameter

import { signTypedData_v4 } from 'eth-sig-util'
import { fromRpcSig } from 'ethereumjs-util'

// ... other imports

import PHROTokenAbi from "./PHROTokenAbi.json"

// ... setup your web3 provider

const phroTokenAddress = "PHRO_TOKEN_ADDRESS"
const phroTokenContract = new web3.eth.Contract(PHROTokenAbi, phroTokenAddress)

const privateKey = "YOUR_PRIVATE_KEY_WITHOUT_0x"
const chainId = 1
const owner = "OWNER_ADDRESS"
const spender = "SPENDER_ADDRESS"
const value = 100 // Amount the spender is permitted
const nonce = 1 // The next valid nonce, use `_nonces()`
const deadline = 1600093162

const permitParams = {
  types: {
    EIP712Domain: [
      { name: "name", type: "string" },
      { name: "version", type: "string" },
      { name: "chainId", type: "uint256" },
      { name: "verifyingContract", type: "address" },
    ],
    Permit: [
      { name: "owner", type: "address" },
      { name: "spender", type: "address" },
      { name: "value", type: "uint256" },
      { name: "nonce", type: "uint256" },
      { name: "deadline", type: "uint256" },
    ],
  },
  primaryType: "Permit",
  domain: {
    name: "Pharo Token",
    version: "1",
    chainId: chainId,
    verifyingContract: phroTokenAddress,
  },
  message: {
    owner,
    spender,
    value,
    nonce,
    deadline,
  },
}

const signature = signTypedData_v4(
  Buffer.from(privateKey, "hex"),
  { data: permitParams }
)

const { v, r, s } = fromRpcSig(signature)

await phroTokenContract.methods
    .permit({
      owner,
      spender,
      value,
      deadline,
      v,
      r,
      s
    })
    .send()
    .catch((e) => {
        throw Error(`Error permitting: ${e.message}`)
    }) 

_nonces()

function _nonces(address owner) public

Returns the next valid nonce to submit when calling permit()

lock()

function lock(bytes32 _reason, uint256 _amount, uint256 _time) public

Locks a specified amount of tokens against an address, for a specified time and reason.

transferWithLock()

function transferWithLock(address _to, bytes32 _reason, uint256 _amount, uint256 _time)

Transfers and locks a specified amount of tokens for an address, for a specified time and reason.

tokensLocked()

function tokensLocked(address _of, bytes32 _reason) public

Returns the tokens locked for a specified address for a specified reason.

tokensLockedAtTime()

function tokensLockedAtTime(address _of, bytes32 _reason, uint256 _time) public

Returns tokens locked for a specified address, for a specified reason at a specific time.

totalBalanceOf()

function totalBalanceOf(address _of, bytes32 _reason) public

Returns the total tokens held by an address (locked and unlocked).

extendLock()

function extendLock(bytes32 _reason, uint256 _time) public

Extends the lock for a specified reason and time.

increaseLockAmount()

function increaseLockAmount(bytes32 _reason, uint256 _amount) public

Increase the number of tokens locked for an address, for a specified reason.

tokensUnlockable()

function tokensUnlockable(address _of, bytes32 _reason) public

Returns unlockable tokens for a specified address, for a specified reason.

unlock()

function unlock(address _of) public onlyOwner

Unlocks the unlockable tokens of a specified address.

getUnlockableTokens()

function getUnlockableTokens(address _of) public

Gets the unlockable tokens of a specified address.

PreviousGovernance ReferenceNextTokenomics

Last updated 1 year ago

Was this helpful?