Skip to content

Commit

Permalink
First Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
victoraranguren committed Nov 13, 2024
0 parents commit 6139228
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 0 deletions.
16 changes: 16 additions & 0 deletions client/client.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
const helloWorld = async () => {
const transaction = await pg.program.methods.helloWorld().transaction();

const transactionID = await web3.sendAndConfirmTransaction(
pg.connection,
transaction,
[pg.wallet.keypair]
);

console.log(
"Transaction Complete: ",
`https://explorer.solana.com/tx/${transactionID}?cluster=devnet`
);
};

helloWorld();
15 changes: 15 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
use anchor_lang::prelude::*;

declare_id!("5UQcesyNGAypwzk8zudC2FL2fGrDYi4DyvEwGmmi7n45");

#[program]
mod hello_anchor {
use super::*;
pub fn hello_world(_ctx: Context<HelloWorld>) -> Result<()> {
msg!("Hello World from Solana Blockchain");
Ok(())
}
}

#[derive(Accounts)]
pub struct HelloWorld {}
25 changes: 25 additions & 0 deletions tests/anchor.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// No imports needed: web3, anchor, pg and more are globally available

describe("HelloWorld", () => {
it("HelloWorld", async () => {
// Generate keypair for the new account
const newAccountKp = new web3.Keypair();

const txHash = await pg.program.methods.helloWorld()
.accounts({
newAccount: newAccountKp.publicKey,
signer: pg.wallet.publicKey,
systemProgram: web3.SystemProgram.programId,
})
.signers([newAccountKp])
.rpc();

console.log(`Use 'solana confirm -v ${txHash} to see the logs`);

// Confirm transaction
await pg.connection.confirmTransaction(txHash);

console.log("Hello World did")

});
});

0 comments on commit 6139228

Please sign in to comment.