I can guide you through the Ethereum Universal Router (UR) rollback issue with the mainnet token.
Introduction
The Universal Router is a decentralized bridge that allows you to use external chains such as Binance Smart Chain or Optimism to launch token sales on the mainnet. However, this can result in the transaction being canceled if the external chain contract is not configured correctly or if there are issues with the proxy chain contract.
Rollback Issue
When a token sale uses the Universal Router and triggers a pull from the mainnet to the target chain, it can cause a rollback error. This happens because:
- The pull function of the mainnet contract expects a specific signature, but the proxy chain contract on the external chain provides a different signature.
- There is an issue with the proxy chain contract that prevents the transaction from being confirmed.
Rollback Troubleshooting
You can fix this issue by modifying the Ethereum-based contracts and updating the configuration of the Universal Router accordingly. Follow these steps:
1. Update the core network contract
Add a “debit” function to the base network contract that accepts a specific signature:
function withdraw(amount) {
//...
return { data: '0x...'}; // Replace with the actual signature
}
Then update your code to call this function and handle any errors:
const { BigNumber } = require('bigNumber.js');
const routerAbi = ...;
const baseNetworkContract = new Contract(baseNetworkAddress, routerAbi, 'BaseNetworkContract');
asynchronous function drawTokens() {
try {
const amount = await baseNetworkContract.withdraw(amount);
//...
} catch (error) {
console.error(error);
// Fix the error and try again
}
}
2. Update the universal router configuration
In the universal router configuration, update the “relayChain” settings to point to the correct contract in the target chain:
const universalRouter = new UniversalRouter({
baseNetworkAddress: '0x...', // Base Network Address
relayChainAddress: '0x...', // Target Chain Address
relayChainContract: 'RelayChainContract', // ABI Relay Chain Contract
});
Remember to replace the addresses and contracts with your actual values.
3. Update the token sale contract
Update the token sale contract’s withdrawal function to use the correct signature:
asynchronous function drawTokens() {
try {
const amount = await baseNetworkContract.withdraw(amount);
//...
} catch (error) {
console.error(error);
// Fix the error and try again
}
}
4. Update the relay chain contract
If you are using a relay contract chain, update its cancel function to use the correct signature:
asynchronous function drawTokens() {
try {
const amount = await baseNetworkContract.withdraw(amount);
//...
} catch (error) {
console.error(error);
// Fix the error and try again
}
}
5. Test your code
After you have made these updates, test your code thoroughly to ensure that the rollback issue has been resolved.
Conclusion
Resolving the recovery issue in the Ethereum public router can be challenging, but by updating your contracts and configuration accordingly, you should be able to resolve this issue and launch the token sale on the network. Don’t forget to test your code thoroughly after making these updates to ensure everything is working as expected.