To launch a new token, you call the newToken function of our portal contract.
/// @notice Create a new meme token
/// @param name The name of the token
/// @param symbol The symbol of the token
/// @param meta The metadata ipfs cid of the token
/// @dev if msg.value is not zero, the caller would be the initial buyer of the token
function newToken(string calldata name, string calldata symbol, string calldata meta)
external
payable
returns (address token);
To launch a token with the "revenue share" enabled, you call the newVanityToken function of our portal contract:
/// @notice Create a new vanity token
/// @param name The name of the token
/// @param symbol The symbol of the token
/// @param meta The metadata URI of the token
/// @param salt The salt for deterministic deployment
/// @param beneficiary The address of the beneficiary
/// @return token The address of the created token
function newVanityToken(
string calldata name,
string calldata symbol,
string calldata meta,
bytes32 salt,
address beneficiary
) external payable returns (address token);
The vanity token must end with "8888" , you must find a possible salt to satisfy this condition. Here is an example typescript to find such a salt:
import { Address, getContractAddress, Hex, keccak256,toBytes, toHex } from 'viem';
import { generatePrivateKey } from 'viem/accounts';
// BSC mainent token implementation address
const TOKEN_IMPLEMENTATION_ADDDRESS = "0x8b4329947e34b6d56d71a3385cac122bade7d78d";
// BSC mainnet portal address
const PORTAL_ADDRESS = "0xe2cE6ab80874Fa9Fa2aAE65D277Dd6B8e65C9De0" as Address;
/// get vanity token address and salt
export async function findSalt(){
// predict the vanity token address based on the salt
const predictVanityTokenAddress = (salt: Hex):Address => {
const bytecode = '0x3d602d80600a3d3981f3363d3d373d3d3d363d73'
+ TOKEN_IMPLEMENTATION_ADDDRESS.slice(2).toLowerCase() // remove 0x prefix
+ '5af43d82803e903d91602b57fd5bf3' as Hex;
return getContractAddress({
from: PORTAL_ADDRESS,
salt: toBytes(salt),
bytecode,
opcode: "CREATE2",
});
}
// the starting seed is a random string (you can use anyting, e.g: UUID, timestamp , etc)
// Here, we use a random private key as the starting seed.
// Then repetively hash the seed until we find a salt that ends with 8888
const seed = generatePrivateKey();
let salt = keccak256(toHex(seed));
while (!predictVanityTokenAddress(salt).endsWith("8888")) {
salt = keccak256(salt);
}
return salt;
}
Events
Whenever a new token is created, a TokenCreated event would emitted from our Portal contract:
/// @notice emitted when a new token is created
///
/// @param ts The timestamp of the event
/// @param creator The address of the creator
/// @param nonce The nonce of the token
/// @param token The address of the token
/// @param name The name of the token
/// @param symbol The symbol of the token
/// @param meta The meta URI of the token
event TokenCreated(
uint256 ts, address creator, uint256 nonce, address token, string name, string symbol, string meta
);