Build A — DEX, validated on chipnet: - scripts/chipnet-amm-usdm-pusd.mjs: USDm/PUSD constant-product swap on the first-party SharePairAMM (ADR-0030); price discovery 1.000→1.440 PUSD/USDm, constant product held. No Cauldron needed (it's mainnet-only). Build B — cross-chain wrap, validated end-to-end across Tron Nile + chipnet: - contracts/DeviantWrapMintIOU.cash: mint-on-attestation IOU covenant — checkDataSig oracle gate, NO BCH backing (dust only; value is the source lock, ADR-0035), replay-bound to the reservoir outpoint. - scripts/chipnet-wrapmint-iou.mjs: BCH leg — genesis reservoir into the covenant, oracle-attested mint of τUSDt, replay rejected by the covenant. - contracts/tron/UsdtLockNile.sol + scripts/tron-deploy-lock.cjs: Nile lock contract (lock/markConsumed/refund), deployed at TXmMRnau9Ct…ZintH. - scripts/tron-bch-wrap.mjs: the oracle watcher — locked 0.5 real USDt on Nile → minted 500000 τUSDt on chipnet → markConsumed. Genuine USDt→τUSDt. Docs (Parameters/ASM DEX/ASM-Multichain.md): which source chains qualify, reverse unwrap, three-tier trust model, source-chain prefix marker, and the cross-chain-redemption design decision (universal IOU = non-goal; per-chain IOUs + BCH AMM swap = the answer; CCTP does not cover BCH). Deps: tronweb ^6.3.0, solc ^0.8.35. Keys/state gitignored. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
72 lines
2.9 KiB
JavaScript
72 lines
2.9 KiB
JavaScript
#!/usr/bin/env node
|
|
/**
|
|
* tron-deploy-lock.cjs — compile + deploy UsdtLockNile.sol on Tron Nile.
|
|
*
|
|
* Build B, Tron leg (step 1): stand up the source-chain lock contract that the
|
|
* oracle watcher will observe. Compiles with evmVersion=istanbul (TVM has no
|
|
* PUSH0, so a Shanghai target would not run). Deploys via TronWeb using the
|
|
* funded Nile key in .tron-nile-keys.json. Saves the address + ABI to
|
|
* .tron-nile-lock.json (gitignored).
|
|
*
|
|
* Run: node scripts/tron-deploy-lock.cjs
|
|
*/
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
const solc = require('solc');
|
|
const mod = require('tronweb');
|
|
const TronWeb = mod.TronWeb || mod.default || mod;
|
|
|
|
const ROOT = path.join(__dirname, '..');
|
|
const KEYS = path.join(ROOT, '.tron-nile-keys.json');
|
|
const SRC = path.join(ROOT, 'contracts/tron/UsdtLockNile.sol');
|
|
const OUT = path.join(ROOT, '.tron-nile-lock.json');
|
|
const USDT = 'TXYZopYRdj2D9XRtbG411XZZ3kM5VkAeBf'; // Nile test USDT (TRC-20)
|
|
const FULL_HOST = 'https://nile.trongrid.io';
|
|
|
|
function compile() {
|
|
const content = fs.readFileSync(SRC, 'utf8');
|
|
const input = {
|
|
language: 'Solidity',
|
|
sources: { 'UsdtLockNile.sol': { content } },
|
|
settings: {
|
|
optimizer: { enabled: true, runs: 200 },
|
|
evmVersion: 'istanbul', // TVM-safe (no PUSH0)
|
|
outputSelection: { '*': { '*': ['abi', 'evm.bytecode.object'] } },
|
|
},
|
|
};
|
|
const out = JSON.parse(solc.compile(JSON.stringify(input)));
|
|
const errs = (out.errors || []).filter((e) => e.severity === 'error');
|
|
if (errs.length) { errs.forEach((e) => console.error(e.formattedMessage)); throw new Error('solc errors'); }
|
|
const c = out.contracts['UsdtLockNile.sol']['UsdtLockNile'];
|
|
return { abi: c.abi, bytecode: c.evm.bytecode.object };
|
|
}
|
|
|
|
async function main() {
|
|
const keys = JSON.parse(fs.readFileSync(KEYS, 'utf8'));
|
|
const { abi, bytecode } = compile();
|
|
console.log(`solc ${solc.version()} → bytecode ${bytecode.length / 2} bytes, ${abi.length} abi entries`);
|
|
|
|
const tw = new TronWeb({ fullHost: FULL_HOST, privateKey: keys.privateKey });
|
|
const operator = keys.address;
|
|
tw.setAddress(operator);
|
|
console.log(`deploying from ${operator} · token ${USDT} · oracle ${operator}`);
|
|
|
|
const instance = await tw.contract().new({
|
|
abi,
|
|
bytecode,
|
|
feeLimit: 1500_000_000, // 1500 TRX cap on energy burn
|
|
callValue: 0,
|
|
userFeePercentage: 100,
|
|
originEnergyLimit: 10_000_000,
|
|
parameters: [USDT, operator], // base58; tronweb encodes
|
|
});
|
|
|
|
const addrHex = instance.address; // 41-prefixed hex
|
|
const addrB58 = tw.address.fromHex(addrHex);
|
|
console.log(`*** UsdtLockNile @ ${addrB58} (${addrHex}) ***`);
|
|
|
|
fs.writeFileSync(OUT, JSON.stringify({ network: 'nile', address: addrB58, addressHex: addrHex, token: USDT, oracle: operator, abi }, null, 2));
|
|
console.log(`saved → .tron-nile-lock.json`);
|
|
}
|
|
|
|
main().catch((e) => { console.error('FAILED:', e?.message ?? e); process.exit(1); });
|