Launching on Sophon

Early partners program

As with any blockchain, you need the native token ($SOPH in our case) to interact with Sophon. However, during the alpha stage, we won't distribute tokens for either Testnet or Mainnet. Instead, you'll interact with our Paymaster, which will sponsor your deployment transactions and interactions with your deployed contracts.

This approach eliminates the need for $SOPH tokens for both you and your users during the alpha stage.

To join the allow list, please complete this form. We'll contact you once you've been added to the Paymaster's allow list.

Deploying on Sophon

Hardhat config

We recommend to scaffold your project using the zksync-cli (documentation).

Here's the network configuration you should add to your setup:

sophonTestnet: {
      url: "https://rpc.testnet.sophon.xyz",
      ethNetwork: "sepolia",
      verifyURL: "https://api-explorer-verify.testnet.sophon.xyz/contract_verification",
      zksync: true,
}

Contract deployment

To deploy a contract without SOPH tokens you need to slightly change your deployment code to use our Paymaster (after we add your deployment wallet to the allow list, which was requested when you filled the form).

Before

import { utils } from "zksync-ethers";

const deployer = new Deployer(hre, wallet);
const artifact = await deployer.loadArtifact("Your_Contract");
const contract = await deployer.deploy(
	artifact,
	constructorArguments || []
);

After

  • Using zksync-ethers v5

    import { utils } from "zksync-ethers";
    
    const deployer = new Deployer(hre, wallet);
    const artifact = await deployer.loadArtifact("Your_Contract");
    
    const params = utils.getPaymasterParams(
      "0x98546B226dbbA8230cf620635a1e4ab01F6A99B2", // Paymaster address
      {
        type: "General",
        innerInput: new Uint8Array(),
      }
    );
    
    const contract = await deployer.deploy(
    	artifact,
    	constructorArguments || [], 
    	{
    	  customData: {
    	    paymasterParams: params,
    	    gasPerPubdata: utils.DEFAULT_GAS_PER_PUBDATA_LIMIT,
    	},
    });
  • Using zksync-ethers v6

    import { utils } from "zksync-ethers";
    
    const deployer = new Deployer(hre, wallet);
    const artifact = await deployer.loadArtifact("Your_Contract");
    
    const params = utils.getPaymasterParams(
      "0x98546B226dbbA8230cf620635a1e4ab01F6A99B2", // Paymaster address
      {
        type: "General",
        innerInput: new Uint8Array(),
      }
    );
    
    // import { utils } from "zksync-ethers";
    const contract = await deployer.deploy(
    	artifact,
    	constructorArguments || [],
    	"create",
    	{
    	  customData: {
    	    paymasterParams: params,
    	    gasPerPubdata: utils.DEFAULT_GAS_PER_PUBDATA_LIMIT,
    	  },
    });

Proxy deployment

To deploy proxy contracts using the paymaster, you must use a beta version of hardhat-zksync-upgradable library. Know more about it in this docs.

import { utils } from "zksync-ethers";

const deployer = new Deployer(hre, wallet);
const artifact = await deployer.loadArtifact("Your_Contract");

// Proxy deployment
await hre.zkUpgrades.deployProxy(deployer.zkWallet, artifact, [initializerFunctionArguments], 
 {
   initializer: "initialize",
   paymasterProxyParams: params,
   paymasterImplParams: params,
 }
);

// Beacon and beacon proxy deployment
const beacon = await hre.zkUpgrades.deployBeacon(deployer.zkWallet, artifact, {
  paymasterParams: params
});

const contract = await hre.zkUpgrades.deployBeaconProxy(deployer.zkWallet, beacon, artifact, constructorArguments || [], {
  paymasterParams: params
});

Deployed contracts interaction through our Paymaster

Our infrastructure will listen for your deployments, and add your contract address to our paymaster. This will allow the Paymaster to also sponsor any transactions sent to your contracts. This might take a few minutes. If you don't see you contract address added after 10 minutes, please reach out to us.

<aside> ❗

Calling a contract just after deployment will cause the error Validation revert: Paymaster validation error: Paymaster is not useable for this transaction as the Sophon infrastructure takes around 30 seconds to whitelist new contracts. Adding a delay will solve the issue

</aside>

Allowing your users to interact with your product using the Paymaster

Now you can get your product to use the Paymaster for all its transactions. Again, you just need to do a minor change to the code sending the transactions.

Before

// Example - minting tokens from a standard erc20 contract
const tx = await erc20.mint(wallet.address, 5)

After

import { utils } from "zksync-ethers";

const paymasterParams = utils.getPaymasterParams(
  "0x98546B226dbbA8230cf620635a1e4ab01F6A99B2", // Paymaster address
  {
    type: "General",
    innerInput: new Uint8Array(),
  }
);

// Example - minting tokens from a standard erc20 contract
const tx = await erc20.mint(wallet.address, 5, {
  customData: {
    gasPerPubdata: utils.DEFAULT_GAS_PER_PUBDATA_LIMIT,
    paymasterParams: paymasterParams,
  },
});

Last updated