STP
Deployment

Deploying a Subscription Contract

Subscription contracts are deployed by invoking the deploySubscription function on the factory contract for a given network. The function uses OpenZeppelin Clones to create a proxy and initialize the contract with supplied parameters.

Deploy Parameters

NameTypeDescription
namestringthe name of the collection. See eip-721 (opens in a new tab)
symbolstringthe symbol of the collection See eip-721 (opens in a new tab)
contractURIstringthe metadata URI for the collection (contract level metadata)
tokenURIstringthe metadata URI for the tokens See eip-721 (opens in a new tab)
tokensPerSeconduint256the number of base tokens required for a single second of time
minimumPurchaseSecondsuint256the minimum number of seconds an account can purchase
rewardBpsuint16the basis points for reward allocations, 0 to disable. See rewards
erc20TokenAddraddressthe address of the ERC20 token used for purchases, or the 0x0 for native
feeConfigIduint256the fee configuration id to use for this deployment See fees

Native Token vs ERC-20

Subscription contracts support native tokens as well as ERC-20 compliant tokens. When minting occurs, the denominated token will be used to purchase time.

️🚫

Subscription contracts do not support rebasing tokens! Do not use them as the denominated token.

⚠️

Subscription contracts support fee taking tokens. The number of tokens transferred on mint will factor in the fee.

Factory Addresses

ChainFactory
Ethereum0xf1d0C43D301d4d0Fa1Fc1A57aDE0d2Fe9ca853f6 (opens in a new tab)
Goerli0x7A5433eD0f561D7c98Fe7133F584923d9552B0E1 (opens in a new tab)
OP Mainnet0x4ABd5D3Af06Ce5356a455Eb5eCDC1f07Aa9C083A (opens in a new tab)
Base0x3BeF7e58a3F357eC98b639df5c24DaC68Ee3A180 (opens in a new tab)
Holesky0xD0884D249B74B7E6C433bB4130a9d3FCa309170E (opens in a new tab)
Zora0x3BeF7e58a3F357eC98b639df5c24DaC68Ee3A180 (opens in a new tab)
Sepolia0xAAe8931adbF1DFC227B2f2eB619450c4fd5E3323 (opens in a new tab)

Deploying

Deploying occurs via the factory contract. The factory contracts are configured in the SDK for all supported networks.

import {
  CollectionConfig,
  prepareDeployment,
} from '@withfabric/protocol-sdks/stpv1';
 
const config: CollectionConfig = {
  name: 'Test',
  symbol: 'TEST',
  contractURI: 'https://example.com/contract',
  tokenURI: 'https://example.com/token',
  tokensPerSecond: 1n,
  minPurchaseSeconds: 60n,
  erc20TokenAddress: Address.ZERO,
  rewardBps: 0n,
  feeId: 0n,
};
 
// Prepare/simulate the deployment and return an async function that can be used to execute it
const deploy = await prepareDeployment(config);
 
// Execute the transaction
const { receipt, contractAddress } = await deploy();