I am trying to deploy the nft contract from the front end.
I am building the contract using forc build
command from the backend and sending the abi and .bin
files to the frontend.
What should be the format of that binary file sent from the backend to the frontend to use that in the code below
const factory = new ContractFactory(byteCode, abi, wallet/provider);
const contract = await factory.deployContract();
The factory will accept a hex string or a byte array. You can use arrayify
or hexlify
on the .bin
file to use it in the FE. Alternatively you can build the project with typegen and it’ll be readily importable to the factory.
Ah that should be fine then, all doc snippets are taken from a feature test. What problem are you having?
const abi = value?.data?.abi;
const byteCode = Buffer.from(value?.data.byteCode, "hex");
const wallet = Wallet.fromAddress(
fuelWalletInfo.walletAddress,
fuelProvider
);
console.log(wallet);
const factory = new ContractFactory(byteCode, abi, wallet);
const contract = await factory.deployContract();
this is the error I am facing
Also, according to the docs
const PRIVATE_KEY = "..."
const provider = await Provider.create(FUEL_NETWORK_URL);
const wallet = Wallet.fromPrivateKey(PRIVATE_KEY, provider);
If I use the fuel wallet extension to make the user connect to the application, is there any other way to create a wallet instance where I can get the unlocked version of fuel wallet
@danielbate
@danielbate Any suggestions how can I solve this.
"dependencies": {
"@fuels/connectors": "^0.5.0",
"axios": "^1.7.2",
"fuels": "^0.89.2",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-hot-toast": "^2.4.1",
"react-icons": "^5.2.1"
},
these are versions of the fuel related packages
Please could you share the full repo? So the issue is that you are attempting to pass a LockedWallet
? For unlocked we need the private key, using the extension we need the user to authorise access using the UI.