Skip to content
Merged
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
2 changes: 1 addition & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
</ul>
<hr />
<h4 align="center">Want to contribute? Then join the Imperium today!</h4>
<p align="center"> To help write content, make art, write code, share it, and or star this repo! All are welcome to the Nexus.</p>
<p align="center">To help write content, make art, write code, share it, and or star this repo! All are welcome to the Nexus.</p>
<hr />
<small>COPYRIGHT © 2025 VIAT, <a href="https://universalweb.io">UNIVERSAL WEB</a>, THE NEXUS</small>
<br />
Expand Down
2 changes: 1 addition & 1 deletion docs/content.html
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ <h4>BROAD CODE OBJECTIVES</h4>
</ul>
<hr />
<h4 align="center">Want to contribute? Then join the Imperium today!</h4>
<p align="center"> To help write content, make art, write code, share it, and or star this repo! All are welcome to the Nexus.</p>
<p align="center">To help write content, make art, write code, share it, and or star this repo! All are welcome to the Nexus.</p>
<hr />
<small>COPYRIGHT © 2025 VIAT, <a href="https://universalweb.io">UNIVERSAL WEB</a>, THE NEXUS</small>
<br />
Expand Down
2 changes: 1 addition & 1 deletion docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ <h4>BROAD CODE OBJECTIVES</h4>
</ul>
<hr />
<h4 align="center">Want to contribute? Then join the Imperium today!</h4>
<p align="center"> To help write content, make art, write code, share it, and or star this repo! All are welcome to the Nexus.</p>
<p align="center">To help write content, make art, write code, share it, and or star this repo! All are welcome to the Nexus.</p>
<hr />
<small>COPYRIGHT © 2025 VIAT, <a href="https://universalweb.io">UNIVERSAL WEB</a>, THE NEXUS</small>
<br />
Expand Down
8 changes: 7 additions & 1 deletion examples/viat.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,15 @@
// Generate two wallets in the Viat network.
// Two wallets interact and send each other some amount of VIAT.
import { Wallet, wallet } from '#viat/index';
import { toSmallestUnit } from '#viat/math/coin';
const amy = await wallet();
const mitzi = await wallet();
console.log('WALLET', amy, mitzi);
const mitziAddress = await mitzi.getAddress();
console.log('MITZI ADDRESS', mitziAddress);
amy.send(1n, mitziAddress);
// Amounts must be in the smallest unit (e.g., wei for Ethereum, satoshi for Bitcoin).
const sendAmount = toSmallestUnit(1n);
const manaAmount = 10000n;
const txBlock = await amy.createTransaction(sendAmount, mitziAddress, manaAmount);
console.log('TX BLOCK', txBlock.block);
console.log('RECEIPT BLOCK', txBlock.receipt.block);
2 changes: 1 addition & 1 deletion viat/blocks/receipt/block.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export class ReceiptBlock extends Block {
}
async configByTransactionBlock(blockObject, config) {
const txBlockData = blockObject.getData();
const txHash = blockObject.getHash();
const txHash = blockObject.block.hash;
this.appendToCore(txBlockData.core, txHash);
}
appendToCore(coreData, txHash) {
Expand Down
8 changes: 4 additions & 4 deletions viat/blocks/transaction/block.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ class TransactionBlock extends Block {
}
// Receipt Hash Link
// Block Hash (TX DATA || Receipt Meta?)
async createReceipt(wallet) {
this.receipt = await receiptBlock(this, wallet);
async createReceipt() {
this.receipt = await receiptBlock(this);
return this;
}
getReceiptPath() {
const filepath = getTransactionPathFromBlock(this);
async getReceiptPath() {
const filepath = await getTransactionPathFromBlock(this);
return filepath;
}
blockSchema = transactionBlockSchema;
Expand Down
22 changes: 17 additions & 5 deletions viat/wallet/wallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,27 @@ export class Wallet extends CryptoID {
await this.initialize(config, optionalArg);
return this;
}
async send(amount, receiver, mana = 1n) {
async createTransaction(amount, receiver, mana = 1n) {
const sender = await this.getAddress();
const txBlock = await transactionBlock({
amount,
receiver,
sender,
mana
core: {
amount,
receiver,
sender,
mana
}
});
await txBlock.finalize();
await txBlock.createReceipt();
await txBlock.receipt.finalize();
console.log('Transaction Block:', txBlock.block);
return txBlock;
}
async send(amount, receiver, mana = 1n) {
const txBlock = await this.createTransaction(amount, receiver, mana);
// Here you would typically send the transaction to the network
// This is a placeholder for the actual sending logic
console.log(`Sending transaction of ${amount} to ${receiver} with mana ${mana}`);
}
}
export function wallet(config) {
Expand Down
Loading