@Kale
호출된 부분에서 문제가 된거 같긴한데 호출된 부분을 봐도 어떤 부분이 오류 인지 몰라서 제가 호출한 부분을 드려서 문의드립니다ㅜㅜ
@Test
public void testBurn() throws Exception{
String testPrivateKey = "0x07f2066d045c19f72479cf3079a8161244bb3a9d0899a3487b6ec00c13596360";
AbstractKeyring deployerKeyring = KlaytnUtils.createFromPrivateKey(testPrivateKey);
KlaytnUtils klaytnUtils = new KlaytnUtils(caverProvider.get(), contractAddress);
klaytnUtils.getCaver().wallet.add(deployerKeyring);
BigInteger tokenId = new BigInteger("13");
TransactionReceipt.TransactionReceiptData receiptData = klaytnUtils.burn(deployerKeyring, tokenId);
log.info("#### receiptData : {}", objectToString(receiptData));
}
-- klaytnUtils.burn 부분
public TransactionReceipt.TransactionReceiptData burn(AbstractKeyring keyring, BigInteger tokenId) throws Exception{
kip17.setSender(keyring);
TransactionReceipt.TransactionReceiptData receiptData = kip17.burn(tokenId);
return receiptData;
}
-- setSender 부분
public void setSender(AbstractKeyring senderKering) {
SendOptions sendOptions = this.getDefaultSendOptions();
sendOptions.setFrom(senderKering.getAddress());
if(!this.getCaver().wallet.isExisted(senderKering.getAddress())){
this.getCaver().wallet.add(senderKering);
}
}
-- KIP17.java (Contract 상속)
public TransactionReceipt.TransactionReceiptData burn(BigInteger tokenId) throws NoSuchMethodException, IOException, InstantiationException, ClassNotFoundException, IllegalAccessException, InvocationTargetException, TransactionException {
return burn(tokenId, this.getDefaultSendOptions());
}
public TransactionReceipt.TransactionReceiptData burn(BigInteger tokenId, SendOptions sendParam) throws NoSuchMethodException, IOException, InstantiationException, ClassNotFoundException, IllegalAccessException, InvocationTargetException, TransactionException {
SendOptions sendOption = determineSendOptions(this, sendParam, FUNCTION_BURN, Arrays.asList(tokenId));
TransactionReceipt.TransactionReceiptData receiptData = this.getMethod(FUNCTION_BURN).send(Arrays.asList(tokenId), sendOption);
return receiptData;
}
private static SendOptions determineSendOptions(KIP17 kip17, SendOptions sendOptions, String functionName, List<Object> argument) throws NoSuchMethodException, IOException, InstantiationException, IllegalAccessException, InvocationTargetException, ClassNotFoundException {
SendOptions newSendOptions = null;
String from = kip17.getDefaultSendOptions().getFrom();
String gas = kip17.getDefaultSendOptions().getGas();
String value = kip17.getDefaultSendOptions().getValue();
Boolean feeDelegation = kip17.getDefaultSendOptions().getFeeDelegation();
String feePayer = kip17.getDefaultSendOptions().getFeePayer();
String feeRatio = kip17.getDefaultSendOptions().getFeeRatio();
if(sendOptions.getFrom() != null) {
from = sendOptions.getFrom();
}
if(sendOptions.getGas() == null) {
//If passed gas fields in sendOptions and defaultSendOptions is null, it estimate gas.
if(gas == null) {
CallObject callObject = CallObject.createCallObject(sendOptions.getFrom());
BigInteger estimateGas = estimateGas(kip17, functionName, callObject, argument);
gas = Numeric.toHexStringWithPrefix(estimateGas);
}
} else {
gas = sendOptions.getGas();
}
~~
}
private static BigInteger estimateGas(KIP17 kip17, String functionName, CallObject callObject, List<Object> arguments) throws NoSuchMethodException, IOException, InstantiationException, IllegalAccessException, InvocationTargetException, ClassNotFoundException {
String gas = kip17.getMethod(functionName).estimateGas(arguments, callObject);
BigDecimal bigDecimal = new BigDecimal(Numeric.toBigInt(gas));
BigInteger gasInteger = bigDecimal.multiply(new BigDecimal(1.5)).toBigInteger();
return gasInteger;
}
이렇게 호출 했을 때 "gas required exceeds allowance or always failing transaction"에러가 발생했습니다