![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
@coral-xyz/anchor
Advanced tools
@coral-xyz/anchor is a framework for Solana's Sealevel runtime providing several developer tools to build, deploy, and interact with smart contracts on the Solana blockchain. It simplifies the process of writing Solana programs by offering a set of Rust macros and a TypeScript client for interacting with these programs.
Smart Contract Development
This code demonstrates how to set up a client to interact with a Solana smart contract using the @coral-xyz/anchor framework. It shows how to load the program's IDL, set up a provider, and call a function on the smart contract.
const anchor = require('@coral-xyz/anchor');
// Define the provider
const provider = anchor.AnchorProvider.env();
anchor.setProvider(provider);
// Load the IDL
const idl = JSON.parse(require('fs').readFileSync('./target/idl/my_program.json', 'utf8'));
// Address of the deployed program
const programId = new anchor.web3.PublicKey('YourProgramPublicKey');
// Generate the program client from IDL
const program = new anchor.Program(idl, programId);
// Interact with the program
async function main() {
// Call a function from the smart contract
await program.rpc.initialize();
}
main().catch(err => console.error(err));
Testing Smart Contracts
This code provides a basic test setup for a Solana smart contract using the @coral-xyz/anchor framework. It uses Mocha for testing and demonstrates how to initialize a program and assert the state of an account.
const anchor = require('@coral-xyz/anchor');
const assert = require('assert');
describe('my-program', () => {
// Configure the client to use the local cluster.
const provider = anchor.AnchorProvider.local();
anchor.setProvider(provider);
const program = anchor.workspace.MyProgram;
it('Initializes the account', async () => {
// Add your test here.
const tx = await program.rpc.initialize();
console.log('Transaction signature', tx);
// Fetch the account and assert its state
const account = await program.account.myAccount.fetch(provider.wallet.publicKey);
assert.ok(account.data.eq(new anchor.BN(0)));
});
});
@solana/web3.js is a JavaScript API for interacting with the Solana blockchain. While it provides lower-level access to Solana's features, it lacks the higher-level abstractions and developer tools that @coral-xyz/anchor offers, such as IDL generation and client-side program interaction.
TypeScript client for Anchor programs.
@coral-xyz/anchor
depends on node.js native modules. Therefore, webpack 5 will not work with current version. You will either need to rollback to webpack 4, or use a polyfill for each missing dependency.[0.30.0] - 2024-04-15
See the Anchor 0.30 release notes for a high-level overview of how to update.
init
and new
(#2698).deploy
(#2705).solana program deploy
command with anchor deploy
(#2709).InstructionData::write_to
implementation (#2733).#[interface(..)]
attribute for instruction discriminator overrides (#2728)..interface(..)
method for instruction discriminator overrides (#2728).anchor-lang
and CLI version compatibility (#2753).idl close
accepts optional --idl-address
parameter (#2760).workspace.members
and workspace.exclude
. (#2785).--test-template
option for init
command (#2805).anchor test
is able to run multiple commands (#2799).@coral-xyz/anchor
package and CLI version compatibility (#2813).repr
s (#2824).accountsPartial
method to keep the old accounts
method behavior (#2824).opts
parameter of AnchorProvider
constructor optional (#2843).--no-idl
flag to the build
command (#2847).prepend
option to MethodBuilder preInstructions
method (#2863).declare_program!
macro (#2857).deactivate_feature
flag to solana-test-validator
config in Anchor.toml (#2872).docs
field for constants (#2887).Event
utility type to get events from bytes (#2897).Lamports
trait operations (#2907).new_from_array
method to Hash
(#2682).resolver = "2"
) (#2676).provider.wallet
in Anchor.toml
(#2696).anchor_version
override (#2704).shmem
feature enabled (#2722).localhost
to 127.0.0.1
, NodeJS 17 IP resolution changes for IPv6 (#2725).try_to_vec
usage while setting the return data in order to reduce heap memory usage (#2744)migrate
command not working without global ts-node
installation (#2767).parse_logs_response
to prevent panics when more than 1 outer instruction exists in logs (#2856).stdsimd
feature compilation error from ahash
when installing the CLI using newer Rust versions (#2867).solana-program
dependency (#2900).TokenAccount
and Mint
Copy
(#2904).cargo build-sbf
the default build command (#2694).overflow-checks
flag (#2716).anchor-deprecated-state
feature (#2717).CLOSED_ACCOUNT_DISCRIMINATOR
(#2726).Option<u8>
rather than u8
(#2730).shared-memory
program (#2747).associated
, account.associated
and account.associatedAddress
methods (#2749).idl upgrade
command closes the IDL buffer account (#2760).--jest
option from the init
command (#2805).idl-build
feature in program Cargo.toml
(#2824).seeds
feature to resolution
and make it enabled by default (#2824).idl parse
command (#2824).idl-parse
and seeds
features (#2824).accounts
method to no longer accept resolvable accounts (#2824).Program
instances use camelCase for everything (#2824).programId
parameter of the Program
constructor (#2864).anchor-syn
crate to the new IDL crate (#2882).#[non_exhaustive]
to IDL enums (#2890).FAQs
Anchor client
The npm package @coral-xyz/anchor receives a total of 109,278 weekly downloads. As such, @coral-xyz/anchor popularity was classified as popular.
We found that @coral-xyz/anchor demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.