Planq Docs
  • Getting Started
    • Getting Started
    • Background
    • Architecture
  • FOR USERS
    • 🔥Crypto Wallets
    • 🦊MetaMask Configuration
    • 🏰Castrum Wallet
      • Castrum Wallet FAQ
      • Supported Chains on Castrum
    • 🦁Brave Wallet
    • 🐸Leap Wallet
    • ⚛️Keplr wallet
    • 🌉Bridges
      • IBC (Planq Chain, other Cosmos chains)
      • Deltaswapp WebApp (BSC, other EVM Chains)
        • Assumptions
        • DELTA Token
        • ERC20 / IBC Conversion
        • EVM Chain Integration
        • Governor
        • Operations
        • Supported Chains and Contracts
        • Updating Testnet
        • Vesting
      • FAQs for Bridge transfers
    • 💡Tips & FAQs
  • FOR DAPP DEVELOPERS
    • 💡Founder FAQs
    • 🏅Hacker's getting started resources
    • 📃Smart Contracts
      • Contract Deployment
      • Contract Verification
      • Multicall & Permit2
      • Best Practices
      • Name Service
      • Polygon ID
      • Token Contract Addresses
    • 💻dApp Creation
      • Free and commercial RPC endpoints
      • Wallet integrations
      • JSON-RPC methods
      • Adress Conversion
    • ⚙️Dev Tools & Integrations
      • Overview of dev tools & integrations
      • Flair
  • FOR NODE HOSTS
    • Running nodes
      • Planq Mainnet
        • Snapshot
        • State-sync
      • Devnet
      • Best Practices
    • Planqd
  • Block Explorers
    • Block Explorer and API Keys
    • Planq EVM Explorer
  • PLANQ CHAIN PROTOCOL
    • Atlas Testnet
    • Whitepaper
    • Chain ID and Address Format
    • Planq General FAQ
    • Genesis
    • Modules
      • module_bank
      • module_distribution
      • module_gov
      • module_mint
      • module_slashing
      • module_staking
      • module_feemarket
    • Chain Details
      • List of parameters
      • Technical glossary
      • Protocol Documentation
    • Privacy Policy
    • Legacy Docs
Powered by GitBook
On this page
  1. FOR DAPP DEVELOPERS
  2. dApp Creation

Adress Conversion

As explained in Chain ID and Address Format, Planq uses the Bech32 address format. In order to convert between a Bech32 format address and an Ethereum format address, we provide the following sample code below:

Python implementation

In order to convert from Bech32 plq... address to a Ethereum 0x... address:

```python
import bech32

bech32_address = input("Please enter a plq address: ")
#bech32_address = "plq1c47uszfujup3ax0d5p4ges3pxa4ne9zqc20pgf"

_, bz = bech32.bech32_decode(bech32_address)
hexbytes=bytes(bech32.convertbits(bz, 5, 8))
eth_address = '0x' + hexbytes.hex()
print(eth_address)
#0xc57DC8093C97031E99EdA06A8CC221376B3c9440
```

Vice versa, in order to convert from an Ethereum 0x... to a Bech32 plq... address:

```python
import bech32

eth_address = input("Please enter a ETH address (0x...): ")
#eth_address = "0xc57DC8093C97031E99EdA06A8CC221376B3c9440"
eth_address_bytes = bytes.fromhex(eth_address[2:])

bz = bech32.convertbits(eth_address_bytes, 8, 5)
bech32_address = bech32.bech32_encode("plq",bz)
print(bech32_address)
#plq1c47uszfujup3ax0d5p4ges3pxa4ne9zqc20pgf
```
PreviousJSON-RPC methodsNextDev Tools & Integrations

Last updated 1 year ago

💻