DEV Community

Cover image for Bitpowr's Customizable Policy Engine
Bitpowr Technologies
Bitpowr Technologies

Posted on

Bitpowr's Customizable Policy Engine

The Bitpowr Safe Contract is a non-custodial smart contract wallet designed to minimize transaction fees and simplify onboarding users to web3 applications with support for multiple chains.

Most EVM chain wallets are typically controlled by a single private key. Each address generated is associated with an account and a corresponding private key for fund access.

However, the Bitpowr Safe Contract introduces a unique approach. It allows for the deployment of a distinct smart contract wallet for each user, which can be controlled by either a deployer's private key, multiple private keys, or individual users' private keys. This offers more control over user onboarding and transaction fee management.

The Bitpowr Safe Contract utilizes the create2 method to generate gasless on-chain wallet addresses, which can be deployed when users deposit funds into the address or at any time.

Benefits

  1. Multi-Chain Support: Ethereum, Polygon, Binance Smart Chain, Tron.
  2. Custodial & Non-Custodial: The Bitpowr Safe Contract can be operated as both a non-custodial wallet or a custodial one, depending on the preferences of the deployer.
  3. Fee Abstraction: Deployers can cover the transaction fees. Fees are only incurred when users deposit funds, allowing flexibility in fee management.
  4. Batch Transaction: Support for batch transferring multiple assets, including ERC20, ERC721, and ERC1155 (work in progress).
  5. Flush: Capability to flush tokens to the deployer's address.
  6. Auto Flush: Native assets like ETH and MATIC are automatically flushed to the master address upon incoming deposits.

Network Support

The Bitpowr Safe Contract is written in Solidity and is technically compatible with all EVM chains.

Currently supported networks:

  1. Ethereum - Mainnet, Ropsten
  2. Polygon - Mainnet, Mumbai
  3. Binance Smart Chain - Mainnet, Testnet
  4. Tron - Mainnet, Shasta

Gas & Transaction Fees

The Bitpowr Safe Contract is a smart contract wallet designed to manage and abstract transaction fees, relieving users of this burden. Transaction fees are covered in native chain assets by the deployer or owner of the wallet.

Sending Out Transactions

To initiate transactions, users need to call the smart contract's transfer command to execute on-chain transfers to the desired addresses. The cost of the transaction is the expense of calling this function, with gas fees incurred based on the gas required to execute the transfer method.

Getting Started

Installation

To start using the Bitpowr SDK, you can install it via npm or yarn:

bashCopy code
$ npm install --save @bitpowr/contract

Enter fullscreen mode Exit fullscreen mode

or

bashCopy code
$ yarn add @bitpowr/contract

Enter fullscreen mode Exit fullscreen mode

Note: An .npmrc file containing our private package registry configuration is required to install the package.

lessCopy code
@bitpowr:registry=https://gitlab.com/api/v4/packages/npm/
//gitlab.com/api/v4/projects/26875049/packages/npm/:_authToken=<sdkToken>
//gitlab.com/api/v4/packages/npm/:_authToken=<sdkToken>

Enter fullscreen mode Exit fullscreen mode

Wallet Contracts Comment

There are two types of EVM chain wallets: Externally Owned Account (EOA) and Smart Contract Wallet. One is deployed on the blockchain, and the other does not require deployment.

Bitpowr Safe utilizes a smart contract wallet, which allows the implementation of custom functionalities, logic, and behaviors supported by the virtual machine.

Bitpowr employs factory contracts to clone contracts on-chain when deploying a new wallet, utilizing the create2 method to generate feeless on-chain wallets.

Bitpowr Safe comprises two main contracts:

  1. AddressFactory: The address factory facilitates address deployment, and predicts addresses using create2.
  2. Address: The Address contract serves as the wallet deployed to manage user funds.

Address Factory

The address factory is a factory proxy contract that aids in cloning and deploying contracts to an address generated uniquely via create2.

Methods

  1. deployAddress: Deploys a proxy contract to a uniquely generated address using a salt passed to the create2 command. This method essentially clones and deploys a previously deployed contract to a new address.
  2. predictAddress: Generates gasless smart contract addresses that can be provided to users without incurring a fee. This ensures that the predicted address is uniquely generated using the given salt and the owner's address, eliminating any address collisions.
  3. predictDeterministicAddress: If you prefer generating a custom salt using a specific language, you can directly pass the salt to this function.

Address

The Address contract is responsible for holding assets and executing on-chain transactions and operations. It automatically flushes incoming native assets to the deployer's/owner's address.

The deployer is, by default, the owner of the address, and ownership can be transferred to another address using the transferOwnership function.

Methods

  1. getBalance: Retrieves the balance of native and ERC20 assets.
  2. transferOwnership: Transfers contract ownership to another address, typically the user's address.
  3. transfer: Executes native and ERC20 transactions to another address, incurring gas fees only for calling the function.
  4. transferToMany: Initiates transfers to multiple addresses in a single transaction, with the option to specify the ERC20 token for the transfer.
  5. flush: Flushes native assets to the deployer's/owner's address.
  6. flushTokens: Flushes a single ERC20 token to the deployer's/owner's address.
  7. flushMultipleTokens: Flushes multiple ERC20 tokens to the deployer's/owner's address.
  8. enableAutoFlush: Enables auto flush for incoming deposits of native assets.
  9. disableAutoFlush: Disables auto flush for incoming deposits of native assets.
  10. changeTransferGasLimit: Adjusts the gas limit for on-chain transfers.

Genesis Contracts

Genesis contracts are templates deployed and stored on the blockchain, which can later be cloned on-chain to create additional contracts. These contracts are built on the Proxy and Factory Contracts. The Address and AddressFactory contracts are deployed to the blockchain as genesis contracts, enabling the generation of gasless addresses, contract deployment, and on-chain asset management while allowing individuals to retain control of their private keys. Bitpowr deploys these contracts on each supported chain, enabling users to clone these contracts on-chain while maintaining their private keys.

Top comments (0)