Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create main.yml #369

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 63 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
const TonWeb = require('tonweb');
const fs = require('fs');

const httpProvider = new TonWeb.HttpProvider('CHAINSTACK_NODE_WITH_jsonRPC');
const tonweb = new TonWeb(httpProvider);

async function generateAndInitializeWallet() {
// Generate a new key pair
const keyPair = TonWeb.utils.nacl.sign.keyPair();

// Create a v4R2 wallet instance
const WalletClass = tonweb.wallet.all['v4R2'];
const wallet = new WalletClass(tonweb.provider, {
publicKey: keyPair.publicKey,
wc: 0
});

// Get the wallet address
const walletAddress = await wallet.getAddress();
const addressString = walletAddress.toString(true, true, true);

console.log('Generated wallet address:', addressString);
console.log('Please send some TON to this address to initialize the wallet.');

// Save the key pair to a file
const keyPairData = {
publicKey: TonWeb.utils.bytesToHex(keyPair.publicKey),
secretKey: TonWeb.utils.bytesToHex(keyPair.secretKey)
};
fs.writeFileSync('wallet_keys.json', JSON.stringify(keyPairData, null, 2));
console.log('Key pair saved to wallet_keys.json');

// Wait for the wallet to be topped up
await waitForBalance(walletAddress);

// Initialize the wallet
console.log('Initializing wallet...');
const deployResult = await wallet.deploy(keyPair.secretKey).send();
console.log('Deployment transaction sent:', deployResult);

console.log('Waiting for deployment to complete...');
await new Promise(resolve => setTimeout(resolve, 10000)); // Wait for 10 seconds

const seqno = await wallet.methods.seqno().call();
if (seqno !== null) {
console.log('Wallet successfully initialized!');
} else {
console.log('Wallet initialization might have failed. Please check the address on a block explorer.');
}
}

async function waitForBalance(address) {
while (true) {
const balance = await tonweb.getBalance(address);
if (balance && balance !== '0') {
console.log('Balance detected:', TonWeb.utils.fromNano(balance), 'TON');
break;
}
await new Promise(resolve => setTimeout(resolve, 5000)); // Check every 5 seconds
}
}

generateAndInitializeWallet().catch(console.error);
43 changes: 43 additions & 0 deletions Altrd
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
const TonWeb = require('tonweb');

const privateKey = IrPhIDMH.j7A6K0cf5ODb7tt9U3whePdO1UXqfth1

const httpProvider = new TonWeb.HttpProvider(Node 23-12-2024 09:52/JsonRPC);
const tonweb = new TonWeb(httpProvider);

async function deployWallet() {UQA40gk4wW3XgJcPiExt5sUuBS3Q0Zp0k9giek_owXPNgzdq
try {
const keyPair = TonWeb.utils.nacl.sign.keyPair.fromSecretKey(TonWeb.utils.hexToBytes(privateKey));
const WalletClass = tonweb.wallet.all['v4R2'];
const wallet = new WalletClass(tonweb.provider, {
publicKey: keyPair.publicKey,
wc: 0
});

const walletAddress = await wallet.getAddress();
console.log(UQA40gk4wW3XgJcPiExt5sUuBS3Q0Zp0k9giek_owXPNgzdq, walletAddress.toString(true, true, true));

const balance = await tonweb.provider.getBalance(walletAddress.toString());
console.log('Wallet balance:', balance);

if (balance === '0') {
console.error('Wallet has no balance. Please add funds before deploying.');
return;
}

const seqno = await wallet.methods.seqno().call();
console.log('Seqno:', seqno);

if (seqno === null) {
console.log('Wallet not deployed. Deploying...');
const deployResult = await wallet.deploy(keyPair.secretKey).send();
console.log('Deploy result:', deployResult);
} else {
console.log('Wallet already deployed. Seqno:', seqno);
}
} catch (error) {
console.error('Unexpected error:', error.message);
}
}

deployWallet();