Skip to content

Commit

Permalink
feat: update readme
Browse files Browse the repository at this point in the history
BREAKING CHANGE: new provider and signer interfaces
  • Loading branch information
janek26 committed Feb 9, 2022
1 parent 4b2a71c commit ed021dc
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ Install starknet with `npm`

```bash
$ npm install starknet
# or
$ npm install starknet@next
```

Import `starknet` and use the [API](https://www.starknetjs.com/modules.html)
Expand All @@ -54,16 +56,18 @@ const CONTRACT_ADDRESS =
"0x03e19baa6cb2078631bcdb34844f3f7879449a544c9ce722681a54af08cff4b9";

/**
* addTransaction() example
* invokeFunction() example
**/

/** Reset the liquidity pool **/
const addTokenResponse = await defaultProvider.addTransaction({
type: "INVOKE_FUNCTION",
contract_address: CONTRACT_ADDRESS,
entry_point_selector: getSelectorFromName("init_pool"),
calldata: ["1000000", "1000000"],
});
const addTokenResponse = await defaultProvider.invokeFunction(
{
contractAddress: CONTRACT_ADDRESS,
entrypoint: "init_pool",
calldata: ["1000000", "1000000"],
},
abi // for displaying purposes only (default implementation has no display/ui)
);
console.log(addTokenResponse);

/**
Expand All @@ -72,25 +76,23 @@ console.log(addTokenResponse);

/** Get the balance of the liquidity pool of token A **/
const poolBalanceTokenA = await defaultProvider.callContract({
contract_address: CONTRACT_ADDRESS,
entry_point_selector: getSelectorFromName("get_pool_token_balance"),
contractAddress: CONTRACT_ADDRESS,
entrypoint: "get_pool_token_balance",
calldata: ["1"],
});
const balanceA = poolBalanceTokenA.result[0];
console.log('token a liquidity pool balance: ', parseInt(balanceA, 16));

/** Get the balance of the liquidity pool of token B **/
const poolBalanceTokenB = await defaultProvider.callContract({
contract_address: CONTRACT_ADDRESS,
entry_point_selector: getSelectorFromName("get_pool_token_balance"),
contractAddress: CONTRACT_ADDRESS,
entrypoint: "get_pool_token_balance",
calldata: ["2"],
});
const balanceB = poolBalanceTokenB.result[0];
console.log('token b liquidity pool balance: ', parseInt(balanceB, 16));
```

For more information about **signing transactions**, please take a look at this [pull request](https://github.com/seanjameshan/starknet.js/pull/51)

## 🌐 API

[Click Here](https://www.starknetjs.com/modules.html)
Expand Down

0 comments on commit ed021dc

Please sign in to comment.