Encrypted transactions are the first privacy primitive released as part of SKALE’s BITE Protocol. An encrypted transaction requires NO changes to existing Solidity contracts and works on all Solidity transactions. It encrypts the input data and to address of the EVM Transaction and requires a threshold decryption operation from the majority of the SKALE Chain validators to be decrypted and executed.
Encrypted transactions are a great way to add an edge against MEV and help protect your onchain strategies from bad actors.
Integration Examples
import { BITE } from '@skalenetwork/bite';
const bite = new BITE('https://your-skale-chain.skale.network');
async function sendEncryptedTransaction(to, data) {
const tx = { to, data };
const encryptedTx = await bite.encryptTransaction(tx);
const txHash = await window.ethereum.request({
method: 'eth_sendTransaction',
params: [encryptedTx],
});
return txHash;
}
import { BITE } from '@skalenetwork/bite';
import { ethers } from 'ethers';
const bite = new BITE('https://your-skale-chain.skale.network');
const provider = new ethers.BrowserProvider(window.ethereum);
const signer = await provider.getSigner();
async function sendEncryptedERC20Transfer(tokenAddress, to, amount) {
const iface = new ethers.Interface([
'function transfer(address to, uint256 amount)'
]);
const data = iface.encodeFunctionData('transfer', [to, amount]);
const tx = { to: tokenAddress, data };
const encryptedTx = await bite.encryptTransaction(tx);
const txResponse = await signer.sendTransaction(encryptedTx);
return txResponse.hash;
}
Resources