quickstart's People
Forkers
zzentenoo cold-briu viktordanneker danielbate isabella232 arunican jojosephstar haammidd ravenclaw696 anhkhoi221020 yash251 block0xhash taylorhaun sskav7 wrule neoronny thomasnz23quickstart's Issues
I cant make this sample work using Svelte
I'm trying to run this same sample using Svelte instead of React. I cloned the repo, ran npm install fuels @fuel-wallet/sdk
inside my new front-end, but nothing seems to work. The catch block in my function logs Error: Unknown field "txCreatedIdx" on type "Coin"
. What am I doing wrong?
Also Im trying to use the account from my browsers wallet, that is something that I done differently from the sample.
Here is the full App.svelte file that I'm using:
<script lang="ts">
import { Provider, Wallet, type WalletLocked } from 'fuels';
import { onMount } from 'svelte';
import { CounterContractAbi__factory } from './contracts';
const CONTRACT_ID = "0x309e4a868535ce161d6fb6cdf29b3ce1c3f3c0f8e7bf812fe34fd1e85b384784"
const provider = new Provider('https://beta-3.fuel.network/graphql');
let connected: boolean = false
let account: string = ""
let count: number = 0
async function connect() {
await window.fuel.connect();
account = await window.fuel.currentAccount();
connected = true
}
async function getCount() {
try {
const wallet: WalletLocked = Wallet.fromAddress(account,provider);
const contract = CounterContractAbi__factory.connect(CONTRACT_ID, wallet);
const { value } = await contract.functions.count().get();
count = (Number(value));
} catch(err) {
console.log(err)
}
}
async function increment() {
try {
const wallet: WalletLocked = Wallet.fromAddress(account,provider);
const contract = CounterContractAbi__factory.connect(CONTRACT_ID, wallet);
await contract.functions.increment().txParams({ gasPrice: "1" }).call();
await getCount()
} catch(err) {
console.log(err)
}
}
onMount(async () => {
await connect();
})
$: {
if (connected) {
getCount()
}
}
</script>
<section>
<p>Counter: {count}</p>
<button on:click={increment}>Increment</button>
</section>
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.