PREREQUISITES:
- NodeJS 18+
- npm / yarn (see package.json)
Massa-web3 is an exhaustive TypeScript library that enables you to communicate with the Massa blockchain. It offers an interface to retrieve data directly from the blockchain, interact with smart contracts, acquire and monitor events, and perform additional actions. The library can be used both in browser environments and Node.js runtime.
Massa-web3
can be used as a library for frameworks.
npm install @massalabs/massa-web3
For maintenance reasons, a standalone version of the library is no longer provided. To use massa-web3
in a vanilla JavaScript project, you will need to use a bundler like Vite.
Create a Vite Project:
Use npx
to create a new Vite project:
npx create-vite@latest my-massa-project --template vanilla
cd my-massa-project
Install Massa-Web3:
Install the Massa-Web3 libraries:
npm install @massalabs/massa-web3
npm install @massalabs/wallet-provider
Import Massa-Web3:
Import the libraries in your index.html
file and make sure to have a wallet installed (here we use massa station as an example):
<script type="module">
import * as massa from "@massalabs/massa-web3";
import * as walletPro from "@massalabs/wallet-provider";
async function main() {
try {
let providerList = await walletPro.providers();
console.log("Providers:", providerList);
const provider = providerList.find(
(provider) => provider.name() === "MASSASTATION" // or BEARBY
);
let accounts = await provider.accounts();
if (accounts.length === 0) {
console.log("No accounts found");
return;
}
console.log("Accounts:", accounts);
const account = accounts[0];
if (!account || !provider) {
return;
}
const client = await massa.ClientFactory.fromWalletProvider(
provider,
account
);
console.log("Client:", client);
} catch (e) {
console.log(e);
}
}
main();
</script>
Run the Vite project:
npm run dev
Massa-web3 documentation
to learn how to use Massa-web3.TypeDoc API
is available for all exported classes, interfaces and methods.We welcome contributions from the community!
If you would like to contribute to massa-web3
, please read the CONTRIBUTING file.
massa-web3
is released under the MIT License.
massa-web3
is developed with love by MassaLabs and powered by a variety of open-source projects.
Generated using TypeDoc