baedrik / snip721-reference-impl Goto Github PK
View Code? Open in Web Editor NEWThis is an implementation of the SNIP-721 Standard with select additional features
License: GNU General Public License v3.0
This is an implementation of the SNIP-721 Standard with select additional features
License: GNU General Public License v3.0
I am following this tutorial https://www.youtube.com/watch?v=jRuSOos9ig4.
In the above tutorial, in the contracts
directory of https://github.com/floAr/FigmentLearn-FromZeroToYourFirstSecretNFT.git
, I run cargo generate --git https://github.com/baedrik/snip721-reference-impl.git --name my-snip721
which worked after installing cargo-generate
with the command cargo install cargo-generate
.
The next step is to run cargo wasm
which fails immediately a bunch of use of undeclared crate or module
for packages like slice
and io
. I also get a lot of not found in this scope
errors.
Are these problems happening because I'm on an m1 mac? How do I fix this and get cargo wasm
to run?
Update
This does not appear to be an m1 mac problem. It fails on my Windows 10 build as well.
Just to reiterate, I did the following commands once in the contracts directory of https://github.com/floAr/FigmentLearn-FromZeroToYourFirstSecretNFT.git
:
cargo generate --git https://github.com/baedrik/snip721-reference-impl.git --name my-snip721
cd my-snip721
cargo wasm
When a ran cargo wasm
on my m1 mac AND my Windows 10 build, I got an endless string of similar errors. They mostly all follow this format:
error[E0433]: failed to resolve: use of undeclared crate or module `slice`
--> /Users/<myusername>/.cargo/registry/src/github.com-1ecc6299db9ec823/byteorder-1.4.3/src/lib.rs:1594:13
|
1594 | slice::from_raw_parts(src.as_ptr() as *const u64, src.len())
| ^^^^^ use of undeclared crate or module `slice`
I also got a bunch of errors that followed this format.
error[E0425]: cannot find function `copy_nonoverlapping` in this scope
--> /Users/<myusername>/.cargo/registry/src/github.com-1ecc6299db9ec823/byteorder-1.4.3/src/lib.rs:1950:13
|
1950 | copy_nonoverlapping(
| ^^^^^^^^^^^^^^^^^^^ not found in this scope
...
2301 | unsafe_write_slice_native!(src, dst, u32);
| ----------------------------------------- in this macro invocation
|
= note: this error originates in the macro `unsafe_write_slice_native` (in Nightly builds, run with -Z macro-backtrace for more info)
So what seems to be the problem? FYI, I'm using the terminal in visual studio code to run the commands. On my Windows build I ran these commands in the vscode bash terminal, powershell terminal, and cmd termial. They all produced the same errors
snip721-reference-impl/src/contract.rs
Line 2443 in 731a5a5
I know it's in case cannot read information for the blockchain but I think may cause some probles since secret-2 is deprecated
I am trying to upload a build of this contract https://github.com/baedrik/snip721-reference-impl.
I build it with:
cargo generate --git https://github.com/baedrik/snip721-reference-impl --name my-snip721
cd my-snip721
make
It compiled the contract to contract.wasm
and contract.wasm.gz
I made this upload script which I reassembled from this code: https://github.com/scrtlabs/SecretJS-Templates/blob/master/5_contracts/main.js and this code https://github.com/floAr/FigmentLearn-FromZeroToYourFirstSecretNFT/blob/main/contract/deploy-nft.js. It looks like this:
const { Wallet, SecretNetworkClient } = require("secretjs");
const fs = require("fs");
// Load environment variables
require("dotenv").config();
const main = async () => {
const wallet = new Wallet(process.env.VITE_MNEMONIC);
// Create a connection to Secret Network node
// Pass in a wallet that can sign transactions
// Docs: https://github.com/scrtlabs/secret.js#secretnetworkclient
const secretjs = new SecretNetworkClient({
url: process.env.__VITE_SECRET_REST_URL,
wallet: wallet,
walletAddress: wallet.address,
chainId: process.env.VITE_SECRET_CHAIN_ID,
});
console.log(`Wallet address=${wallet.address}`);
// 2. Upload the contract wasm
const wasm = fs.readFileSync('my-snip721/contract.wasm');
console.log('Uploading contract');
const tx = await secretjs.tx.compute.storeCode(
{
sender: wallet.address,
wasm_byte_code: wasm,
source: "https://github.com/baedrik/snip721-reference-impl",
builder: "baedrik",
},
{
gasLimit: 1_000_000,
}
);
console.log(tx);
const codeId = Number(
tx.arrayLog.find((log) => log.type === "message" && log.key === "code_id")
.value
);
console.log("codeId: ", codeId);
// contract hash, useful for contract composition
const contractCodeHash = (await secretjs.query.compute.codeHashByCodeId({code_id: codeId})).code_hash;
console.log(`Contract hash: ${contractCodeHash}`);
};
main();
When I run the script with node <SCRIPT NAME HERE>.js
, I get this error:
TypeError: Cannot read properties of undefined (reading 'find')
Notice that I'm logging tx
which looks like this after I format it to json:
{
"height": 0,
"timestamp": "",
"transactionHash": "LONG STRING HERE...",
"code": 18,
"codespace": "sdk",
"info": "",
"tx": {
"@type": "/cosmos.tx.v1beta1.Tx",
"body": {
"messages": ["Array"],
"memo": "",
"timeout_height": "0",
"extension_options": [],
"non_critical_extension_options": []
},
"auth_info": { "signer_infos": ["Array"], "fee": ["Object"] },
"signatures": [
"ANOTHER LONG STRING HERE..."
]
},
"rawLog": "builder invalid: invalid request",
"jsonLog": "undefined",
"arrayLog": "undefined",
"events": [],
"data": [],
"gasUsed": 822,
"gasWanted": 0,
"ibcResponses": []
}
arrayLog
is undefined. So how do I get this snip 721 compiled contract to upload to Secret Network?
Hi @baedrik,
I have clone the repo and switched to use 1.46.0 stable for rust version with the wasm target but have not been able to compile the code to wasm.
Error:
error: failed to run custom build command for `secp256k1-sys v0.4.1`
--- stdout
TARGET = Some("wasm32-unknown-unknown")
OPT_LEVEL = Some("3")
HOST = Some("x86_64-apple-darwin")
CC_wasm32-unknown-unknown = None
CC_wasm32_unknown_unknown = None
TARGET_CC = None
CC = None
CFLAGS_wasm32-unknown-unknown = None
CFLAGS_wasm32_unknown_unknown = None
TARGET_CFLAGS = None
CFLAGS = None
CRATE_CC_NO_DEFAULTS = None
DEBUG = Some("false")
CC_wasm32-unknown-unknown = None
CC_wasm32_unknown_unknown = None
TARGET_CC = None
CC = None
CFLAGS_wasm32-unknown-unknown = None
CFLAGS_wasm32_unknown_unknown = None
TARGET_CFLAGS = None
CFLAGS = None
CRATE_CC_NO_DEFAULTS = None
running: "clang" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "--target=wasm32-unknown-unknown" "-I" "depend/secp256k1/" "-I" "depend/secp256k1/include" "-I" "depend/secp256k1/src" "-I" "wasm-sysroot" "-Wall" "-Wextra" "-DSECP256K1_BUILD=1" "-DSECP256K1_API=" "-DENABLE_MODULE_ECDH=1" "-DENABLE_MODULE_SCHNORRSIG=1" "-DENABLE_MODULE_EXTRAKEYS=1" "-DECMULT_GEN_PREC_BITS=4" "-DUSE_NUM_NONE=1" "-DUSE_FIELD_INV_BUILTIN=1" "-DUSE_SCALAR_INV_BUILTIN=1" "-DECMULT_WINDOW_SIZE=15" "-DUSE_EXTERNAL_DEFAULT_CALLBACKS=1" "-o" "/Users/belsy/snip721-reference-impl/target/wasm32-unknown-unknown/release/build/secp256k1-sys-7f53b194f4029c2b/out/depend/secp256k1/contrib/lax_der_parsing.o" "-c" "depend/secp256k1/contrib/lax_der_parsing.c"
cargo:warning=error: unable to create target: 'No available targets are compatible with triple "wasm32-unknown-unknown"'
cargo:warning=1 error generated.
exit code: 1
--- stderr
am I missing something?
When attempting to run the secret contract optimizer with this repo as part of this Figment Learn tutorial, it currently fails to build the uint
crate with the following error:
error: package `uint v0.9.3` cannot be built because it requires rustc 1.56.1 or newer,
while the currently active rustc version is 1.56.0
make: *** [compile-optimized-reproducible] Error 101
This was brought to my attention by @MarkH1994 on the Figment Devs discord server. We were able to determine that version 0.9.0 of the uint
crate works in this scenario because it doesn't require a higher rustc
version than the Docker container has installed.
@baedrik Would it be preferable to try getting the contract optimizer Docker image updated to use a higher version of rustc
? I just don't know who maintains it or I'd ask directly.
Thanks for your assistance! ๐
env.block.random
could probably be used for entropy instead of having the user specify it as of secret v1.9.0, what are your thoughts on making entropy optional or removing it entirely? @baedrik
I made a branch w/ it removed for example:
https://github.com/eqoty-labs/snip721-reference-impl/tree/remove-entropy
Hey I just realized that this project is GPL-3 licensed. Does that mean that any NFT I implement with this repo has to have the same license? Like if I made a cool 3D art file that was in any way code generated, would I have to release the source code? Also, I use a svelte frontend for an NFT minting dapp similar to the code in this repo https://github.com/floAr/FigmentLearn-FromZeroToYourFirstSecretNFT. Does that mean I have to make my whole dapp open source because I used https://github.com/baedrik/snip721-reference-impl to make the actual NFTs?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.