Skip to content

Integration

The main reason you want to integrate Pablock Smart Contract in your own smart contract is to enable meta transaction feature and allow your user to send transactions to the blockchain.

The meta transaction feature allows the contract to be used also in a standard way and make it compatible with a standard wallet.

Installation

npm install git+https://github.com/bcode-tech/Pablock-Smart-Contracts

or

yarn add git+https://github.com/bcode-tech/Pablock-Smart-Contracts

Usage

Once installed, use PablockMetaTranasactionReceiver to enable Pablock meta transaction on your contract.

pragma solidity 0.8.9;
import "pablock-smart-contract/contract/PablockMetaTxReceiver.sol";

contract MyContract is PablockMetaTxReceiver {
  constructor(address metaTxAddress)
    PablockMetaTxReceiver("MyContract", "0.0.1")
  {
    setMetaTransaction(metaTxAddress);
  }
}

metaTxAddress rappresents the deployment address of EIP712MetaTransaction deployed by Bcode from the Pablock ecosystem. It's referrend in Introduction page as PABLOCK_META_TRANSACTION.

It's a best practice to define a public function that call the internal setMetaTransaction function of the EIP712MetaTransaction contract. This allows to reinitialize the meta transaction address if it'll be any contract upgrade on Pablock side.